summaryrefslogtreecommitdiff
path: root/pdf-over-gui/src/main/java
diff options
context:
space:
mode:
authortkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:07:45 +0000
committertkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7>2013-04-10 19:07:45 +0000
commit2b57f9240540a2d26913f2f96c38918fe9004e79 (patch)
tree4581178d7fd43ca7c7e1b33ce23b37ad81209168 /pdf-over-gui/src/main/java
parentfe4ba84c9bb717aba073aa5b74502d176e00b7ff (diff)
downloadpdf-over-2b57f9240540a2d26913f2f96c38918fe9004e79.tar.gz
pdf-over-2b57f9240540a2d26913f2f96c38918fe9004e79.tar.bz2
pdf-over-2b57f9240540a2d26913f2f96c38918fe9004e79.zip
Center window if possible
Note: not tested git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@147 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main/java')
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
index 7b57d46d..c109f6bd 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
@@ -21,17 +21,20 @@ import java.util.EnumMap;
import java.util.Map;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWTError;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -171,6 +174,18 @@ public class MainWindow {
protected void createContents() {
this.shell = new Shell();
getShell().setSize(1024, 768);
+ try {
+ Display display = new Display();
+ Monitor primary = display.getPrimaryMonitor();
+ Rectangle bounds = primary.getBounds();
+ Rectangle main = this.shell.getBounds();
+ this.shell.setLocation(
+ bounds.x + (bounds.width - main.width) / 2,
+ bounds.y + (bounds.height - main.height) / 2);
+ }
+ catch (SWTError e) {
+ log.debug("Cannot get display", e); //$NON-NLS-1$
+ }
getShell().setText(Messages.getString("main.title")); //$NON-NLS-1$
ImageData data = new ImageData(this.getClass().getResourceAsStream("/icons/icon.png"));//$NON-NLS-1$