source: branches/wsgi/packages/sipb-xen-vnc-client/code/AuthPanel.java @ 2578

Last change on this file since 2578 was 66, checked in by quentin, 17 years ago

Initial checkin of modified Java VNC viewer for use as remote console

File size: 3.1 KB
Line 
1//
2//  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
3//  Copyright (C) 2002-2006 Constantin Kaplinsky.  All Rights Reserved.
4//
5//  This is free software; you can redistribute it and/or modify
6//  it under the terms of the GNU General Public License as published by
7//  the Free Software Foundation; either version 2 of the License, or
8//  (at your option) any later version.
9//
10//  This software is distributed in the hope that it will be useful,
11//  but WITHOUT ANY WARRANTY; without even the implied warranty of
12//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13//  GNU General Public License for more details.
14//
15//  You should have received a copy of the GNU General Public License
16//  along with this software; if not, write to the Free Software
17//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
18//  USA.
19//
20
21import java.awt.*;
22import java.awt.event.*;
23
24//
25// The panel which implements the user authentication scheme
26//
27
28class AuthPanel extends Panel implements ActionListener {
29
30  TextField passwordField;
31  Button okButton;
32
33  //
34  // Constructor.
35  //
36
37  public AuthPanel(VncViewer viewer)
38  {
39    Label titleLabel = new Label("VNC Authentication", Label.CENTER);
40    titleLabel.setFont(new Font("Helvetica", Font.BOLD, 18));
41
42    Label promptLabel = new Label("Password:", Label.CENTER);
43
44    passwordField = new TextField(10);
45    passwordField.setForeground(Color.black);
46    passwordField.setBackground(Color.white);
47    passwordField.setEchoChar('*');
48
49    okButton = new Button("OK");
50
51    GridBagLayout gridbag = new GridBagLayout();
52    GridBagConstraints gbc = new GridBagConstraints();
53
54    setLayout(gridbag);
55
56    gbc.gridwidth = GridBagConstraints.REMAINDER;
57    gbc.insets = new Insets(0,0,20,0);
58    gridbag.setConstraints(titleLabel,gbc);
59    add(titleLabel);
60
61    gbc.fill = GridBagConstraints.NONE;
62    gbc.gridwidth = 1;
63    gbc.insets = new Insets(0,0,0,0);
64    gridbag.setConstraints(promptLabel,gbc);
65    add(promptLabel);
66
67    gridbag.setConstraints(passwordField,gbc);
68    add(passwordField);
69    passwordField.addActionListener(this);
70
71    // gbc.ipady = 10;
72    gbc.gridwidth = GridBagConstraints.REMAINDER;
73    gbc.fill = GridBagConstraints.BOTH;
74    gbc.insets = new Insets(0,20,0,0);
75    gbc.ipadx = 30;
76    gridbag.setConstraints(okButton,gbc);
77    add(okButton);
78    okButton.addActionListener(this);
79  }
80
81  //
82  // Move keyboard focus to the default object, that is, the password
83  // text field.
84  //
85
86  public void moveFocusToDefaultField()
87  {
88    passwordField.requestFocus();
89  }
90
91  //
92  // This method is called when a button is pressed or return is
93  // pressed in the password text field.
94  //
95
96  public synchronized void actionPerformed(ActionEvent evt)
97  {
98    if (evt.getSource() == passwordField || evt.getSource() == okButton) {
99      passwordField.setEnabled(false);
100      notify();
101    }
102  }
103
104  //
105  // Wait for user entering a password, and return it as String.
106  //
107
108  public synchronized String getPassword() throws Exception
109  {
110    try {
111      wait();
112    } catch (InterruptedException e) { }
113    return passwordField.getText();
114  }
115
116}
Note: See TracBrowser for help on using the repository browser.