set dialog locations relative to parent window, otherwise dialogs appear on wrong screen in multi-monitor configurations.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4732 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/com/tigervnc/vncviewer/Dialog.java b/java/com/tigervnc/vncviewer/Dialog.java
index d6fdd1b..563a471 100644
--- a/java/com/tigervnc/vncviewer/Dialog.java
+++ b/java/com/tigervnc/vncviewer/Dialog.java
@@ -41,15 +41,19 @@
     //addWindowListener(this);
   }
 
-  public boolean showDialog() {
+  public boolean showDialog(Component c) {
     ok = false;
     done = false;
     initDialog();
-    Dimension dpySize = getToolkit().getScreenSize();
-    Dimension mySize = getSize();
-    int x = (dpySize.width - mySize.width) / 2;
-    int y = (dpySize.height - mySize.height) / 2;
-    setLocation(x, y);
+    if (c != null) {
+      setLocationRelativeTo(c);
+    } else {
+      Dimension dpySize = getToolkit().getScreenSize();
+      Dimension mySize = getSize();
+      int x = (dpySize.width - mySize.width) / 2;
+      int y = (dpySize.height - mySize.height) / 2;
+      setLocation(x, y);
+    }
     ClassLoader cl = this.getClass().getClassLoader();
     ImageIcon icon = new ImageIcon(cl.getResource("com/tigervnc/vncviewer/tigervnc.ico"));
     setIconImage(icon.getImage());
@@ -69,6 +73,10 @@
     return ok;
   }
 
+  public boolean showDialog() {
+    return showDialog(null);
+  }
+
   public void endDialog() {
     done = true;
     setVisible(false);
diff --git a/java/com/tigervnc/vncviewer/F8Menu.java b/java/com/tigervnc/vncviewer/F8Menu.java
index 375849c..1571761 100644
--- a/java/com/tigervnc/vncviewer/F8Menu.java
+++ b/java/com/tigervnc/vncviewer/F8Menu.java
@@ -96,7 +96,7 @@
       if (cc.fullScreen) cc.toggleFullScreen();
       cc.viewport.setExtendedState(JFrame.MAXIMIZED_BOTH);
     } else if (actionMatch(ev, clipboard)) {
-      cc.clipboardDialog.showDialog();
+      cc.clipboardDialog.showDialog(cc.viewport);
     } else if (actionMatch(ev, f8)) {
       cc.writeKeyEvent(cc.menuKey, true);
       cc.writeKeyEvent(cc.menuKey, false);
@@ -112,7 +112,7 @@
     } else if (actionMatch(ev, newConn)) {
       VncViewer.newViewer(cc.viewer);
     } else if (actionMatch(ev, options)) {
-      cc.options.showDialog();
+      cc.options.showDialog(cc.viewport);
     } else if (actionMatch(ev, info)) {
       cc.showInfo();
     } else if (actionMatch(ev, about)) {
diff --git a/java/com/tigervnc/vncviewer/ServerDialog.java b/java/com/tigervnc/vncviewer/ServerDialog.java
index f5e5614..0f32a96 100644
--- a/java/com/tigervnc/vncviewer/ServerDialog.java
+++ b/java/com/tigervnc/vncviewer/ServerDialog.java
@@ -119,7 +119,7 @@
       ok = false;
       endDialog();
     } else if (s instanceof JButton && (JButton)s == optionsButton) {
-      options.showDialog();
+      options.showDialog(this);
     } else if (s instanceof JButton && (JButton)s == aboutButton) {
       cc.showAbout();
     } else if (s instanceof JComboBox && (JComboBox)s == server) {