aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/tigervnc/vncviewer/AuthPanel.java13
-rw-r--r--java/src/com/tigervnc/vncviewer/VncViewer.java31
2 files changed, 40 insertions, 4 deletions
diff --git a/java/src/com/tigervnc/vncviewer/AuthPanel.java b/java/src/com/tigervnc/vncviewer/AuthPanel.java
index 04d3bdec..a23758e4 100644
--- a/java/src/com/tigervnc/vncviewer/AuthPanel.java
+++ b/java/src/com/tigervnc/vncviewer/AuthPanel.java
@@ -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");
diff --git a/java/src/com/tigervnc/vncviewer/VncViewer.java b/java/src/com/tigervnc/vncviewer/VncViewer.java
index 711b1c95..19541afe 100644
--- a/java/src/com/tigervnc/vncviewer/VncViewer.java
+++ b/java/src/com/tigervnc/vncviewer/VncViewer.java
@@ -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;