diff options
| author | Jonathan Bauer | 2014-09-16 13:21:56 +0200 |
|---|---|---|
| committer | Jonathan Bauer | 2014-09-16 13:21:56 +0200 |
| commit | dad8d7d51aedeb50bfa8d12cac7220ea7c0c4a47 (patch) | |
| tree | 0781d13a3cab50a6eaca6b5b533589cb59e32e27 /dozentenmodul/src | |
| parent | [client] continue to main window even if getting the news fails (diff) | |
| download | tutor-module-dad8d7d51aedeb50bfa8d12cac7220ea7c0c4a47.tar.gz tutor-module-dad8d7d51aedeb50bfa8d12cac7220ea7c0c4a47.tar.xz tutor-module-dad8d7d51aedeb50bfa8d12cac7220ea7c0c4a47.zip | |
[client] center GUIs in the primary display only
this fixes the GUIs beeing split over 2 monitors in a dual-head setup
Diffstat (limited to 'dozentenmodul/src')
| -rw-r--r-- | dozentenmodul/src/main/java/util/GuiOrganizer.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/dozentenmodul/src/main/java/util/GuiOrganizer.java b/dozentenmodul/src/main/java/util/GuiOrganizer.java index 5d6b2de8..edc16cef 100644 --- a/dozentenmodul/src/main/java/util/GuiOrganizer.java +++ b/dozentenmodul/src/main/java/util/GuiOrganizer.java @@ -1,19 +1,26 @@ 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) { - Dimension dm = Toolkit.getDefaultToolkit().getScreenSize(); - double width = dm.getWidth(); - double height = dm.getHeight(); + + 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; double xPosition = (width / 2 - gui.getWidth() / 2); double yPosition = (height / 2 - gui.getHeight() / 2); gui.setLocation((int) xPosition, (int) yPosition); } - } |
