Set focus to password field in UserDialog
Fixes issue #616
diff --git a/java/com/tigervnc/vncviewer/UserDialog.java b/java/com/tigervnc/vncviewer/UserDialog.java
index dfced98..f3ca726 100644
--- a/java/com/tigervnc/vncviewer/UserDialog.java
+++ b/java/com/tigervnc/vncviewer/UserDialog.java
@@ -100,7 +100,6 @@
JDialog win;
JLabel banner;
JTextField username = null;
- JPasswordField passwd = null;
JLayer icon;
int y;
@@ -156,7 +155,7 @@
passwdLabel.setBounds(70, y, msg.getSize().width-70-10, 20);
msg.add(passwdLabel);
y += 20 + 5;
- passwd = new JPasswordField(30);
+ final JPasswordField passwd = new JPasswordField(30);
passwd.setBounds(70, y, msg.getSize().width-70-10, 25);
msg.add(passwd);
y += 25 + 5;
@@ -169,7 +168,12 @@
OK_CANCEL_OPTION,
null, //do not use a custom Icon
options, //the titles of buttons
- options[0]);//default button title
+ options[0]){//default button title
+ @Override
+ public void selectInitialValue() {
+ passwd.requestFocusInWindow();
+ }
+ };
pane.setBorder(new EmptyBorder(0,0,0,0));
Component c = pane.getComponent(pane.getComponentCount()-1);
((JComponent)c).setBorder(new EmptyBorder(0,0,10,10));