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");
// 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;