]> source.dussan.org Git - tigervnc.git/commitdiff
[Development] java: Support asking for a user name. (Martin Koegler)
authorAdam Tkac <atkac@redhat.com>
Thu, 11 Nov 2010 13:25:14 +0000 (13:25 +0000)
committerAdam Tkac <atkac@redhat.com>
Thu, 11 Nov 2010 13:25:14 +0000 (13:25 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4192 3789f03b-4d11-0410-bbf8-ca57d06f2519

java/src/com/tigervnc/vncviewer/AuthPanel.java
java/src/com/tigervnc/vncviewer/VncViewer.java

index 04d3bdec510a8b4a026a2253acf9d97321c34a30..a23758e4ba9dad05aea882b77bca36830c48163e 100644 (file)
@@ -31,22 +31,29 @@ class AuthPanel extends Panel implements ActionListener {
 
   TextField passwordField;
   Button okButton;
+  boolean AskPassword;
 
   //
   // Constructor.
   //
 
-  public AuthPanel(VncViewer viewer)
+  public AuthPanel(VncViewer viewer, boolean askpassword)
   {
+    AskPassword = askpassword;
     Label titleLabel = new Label("VNC Authentication", Label.CENTER);
     titleLabel.setFont(new Font("Helvetica", Font.BOLD, 18));
 
-    Label promptLabel = new Label("Password:", Label.CENTER);
+    Label promptLabel;
+    if (AskPassword)
+      promptLabel = new Label("Password:", Label.CENTER);
+    else
+      promptLabel = new Label("User:", Label.CENTER);
 
     passwordField = new TextField(10);
     passwordField.setForeground(Color.black);
     passwordField.setBackground(Color.white);
-    passwordField.setEchoChar('*');
+    if (AskPassword)
+      passwordField.setEchoChar('*');
 
     okButton = new Button("OK");
 
index 711b1c95a0ff92c257a6694b0e76d362ca21b75b..19541afe9718523cfe2c5d9c2a9a1d936c3d7670 100644 (file)
@@ -437,11 +437,40 @@ public class VncViewer extends java.applet.Applet
   // Show an authentication panel.
   //
 
+  String askUser() throws Exception
+  {
+    showConnectionStatus(null);
+
+    AuthPanel authPanel = new AuthPanel(this, false);
+
+    GridBagConstraints gbc = new GridBagConstraints();
+    gbc.gridwidth = GridBagConstraints.REMAINDER;
+    gbc.anchor = GridBagConstraints.NORTHWEST;
+    gbc.weightx = 1.0;
+    gbc.weighty = 1.0;
+    gbc.ipadx = 100;
+    gbc.ipady = 50;
+    gridbag.setConstraints(authPanel, gbc);
+    vncContainer.add(authPanel);
+
+    if (inSeparateFrame) {
+      vncFrame.pack();
+    } else {
+      validate();
+    }
+
+    authPanel.moveFocusToDefaultField();
+    String pw = authPanel.getPassword();
+    vncContainer.remove(authPanel);
+
+    return pw;
+  }
+
   String askPassword() throws Exception
   {
     showConnectionStatus(null);
 
-    AuthPanel authPanel = new AuthPanel(this);
+    AuthPanel authPanel = new AuthPanel(this, true);
 
     GridBagConstraints gbc = new GridBagConstraints();
     gbc.gridwidth = GridBagConstraints.REMAINDER;