diff options
Diffstat (limited to 'dozentenmodul/src/main/java/util')
| -rw-r--r-- | dozentenmodul/src/main/java/util/GuiOrganizer.java | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/dozentenmodul/src/main/java/util/GuiOrganizer.java b/dozentenmodul/src/main/java/util/GuiOrganizer.java index edc16cef..5d6b2de8 100644 --- a/dozentenmodul/src/main/java/util/GuiOrganizer.java +++ b/dozentenmodul/src/main/java/util/GuiOrganizer.java @@ -1,26 +1,19 @@ package util; +import java.awt.Dimension; +import java.awt.Toolkit; import java.awt.Window; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Display; public abstract class GuiOrganizer { /* receive GUI, set it to center of the screen */ public static void centerGUI(Window gui) { - - Display display = new Display(); - - // detect bounds of primary display. - Rectangle rect = display.getPrimaryMonitor().getBounds(); - - // without this, we get an expection, not sure what this does though :) - display.dispose(); - - double width = rect.width; - double height = rect.height; + Dimension dm = Toolkit.getDefaultToolkit().getScreenSize(); + double width = dm.getWidth(); + double height = dm.getHeight(); double xPosition = (width / 2 - gui.getWidth() / 2); double yPosition = (height / 2 - gui.getHeight() / 2); gui.setLocation((int) xPosition, (int) yPosition); } + } |
