summaryrefslogtreecommitdiff
path: root/trunk/pdf-over-gui/src
diff options
context:
space:
mode:
authortkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:51 +0000
committertkellner <tkellner@3a0b52a2-8410-0410-bc02-ff6273a87459>2012-10-31 16:36:51 +0000
commit6d723300518fad8e735eda4eaea57feb4feeddd2 (patch)
tree65f3d9895b2d515c84920ac6f2bcbfdb3fa4c8f0 /trunk/pdf-over-gui/src
parent114b82daf8a6ef8450feeaf3a1f2ffcc229a12c3 (diff)
downloadpdf-over-6d723300518fad8e735eda4eaea57feb4feeddd2.tar.gz
pdf-over-6d723300518fad8e735eda4eaea57feb4feeddd2.tar.bz2
pdf-over-6d723300518fad8e735eda4eaea57feb4feeddd2.zip
Center window if possible
Note: not tested git-svn-id: https://svn.iaik.tugraz.at/svn/egiz/prj/current/12PDF-OVER-4.0@12733 3a0b52a2-8410-0410-bc02-ff6273a87459
Diffstat (limited to 'trunk/pdf-over-gui/src')
-rw-r--r--trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
index 7b57d46d..c109f6bd 100644
--- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/MainWindow.java
+++ b/trunk/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$