diff options
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover')
-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(); |