diff options
author | Tobias Kellner <imcybot@gmail.com> | 2015-10-12 04:44:28 +0200 |
---|---|---|
committer | Tobias Kellner <imcybot@gmail.com> | 2015-10-12 08:35:41 +0200 |
commit | d23140ea4818d74dab73c5265e68e2d3127ef40d (patch) | |
tree | 01b44b4e2e92dbdf336a1638643a71008cd861b8 /pdf-over-gui/src/main/java/at | |
parent | b2f26fe3ab7cd195b0121cab698eac3d1fc18d1c (diff) | |
download | mocca-d23140ea4818d74dab73c5265e68e2d3127ef40d.tar.gz mocca-d23140ea4818d74dab73c5265e68e2d3127ef40d.tar.bz2 mocca-d23140ea4818d74dab73c5265e68e2d3127ef40d.zip |
Center input dialog on main window
Diffstat (limited to 'pdf-over-gui/src/main/java/at')
-rw-r--r-- | pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java index 80c967a6..88cf9e87 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/controls/InputDialog.java @@ -19,6 +19,7 @@ package at.asit.pdfover.gui.controls; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -96,12 +97,18 @@ public class InputDialog extends org.eclipse.swt.widgets.Dialog { * @return the input */ public String open() { - Shell shell = new Shell(getParent(), getStyle()); + Shell parent = getParent(); + Shell shell = new Shell(parent, getStyle()); shell.setText(getText()); createContents(shell); shell.pack(); shell.open(); - Display display = getParent().getDisplay(); + Display display = parent.getDisplay(); + Rectangle bounds = parent.getBounds(); + Rectangle main = shell.getBounds(); + shell.setLocation( + bounds.x + (bounds.width - main.width) / 2, + bounds.y + (bounds.height - main.height) / 2); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); |