annotate src/myVncClient/AuthPanel.java @ 18:4881586aead9

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