root / tags / v1_0_2_Build_896 / libraries / libIverUtiles / src / com / iver / utiles / swing / JPasswordDlg.java @ 10391
History | View | Annotate | Download (6.88 KB)
1 |
/*
|
---|---|
2 |
* Created on 07-oct-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or
|
9 |
* modify it under the terms of the GNU General Public License
|
10 |
* as published by the Free Software Foundation; either version 2
|
11 |
* of the License, or (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.utiles.swing; |
45 |
|
46 |
import java.awt.event.KeyEvent; |
47 |
import java.awt.event.WindowAdapter; |
48 |
import java.awt.event.WindowEvent; |
49 |
|
50 |
import javax.swing.JButton; |
51 |
import javax.swing.JDialog; |
52 |
import javax.swing.JEditorPane; |
53 |
import javax.swing.JPanel; |
54 |
import javax.swing.JPasswordField; |
55 |
import javax.swing.JTextArea; |
56 |
|
57 |
public class JPasswordDlg extends JDialog { |
58 |
|
59 |
private JPanel jContentPane = null; |
60 |
|
61 |
private JButton jButtonOK = null; |
62 |
|
63 |
private JButton jButton1 = null; |
64 |
|
65 |
private JPasswordField jPasswordField = null; |
66 |
|
67 |
private String password = null; |
68 |
|
69 |
private JEditorPane jEditorPane = null; |
70 |
|
71 |
private JTextArea jLblMensaje = null; |
72 |
|
73 |
private WindowEventsHandler windowHandler = new WindowEventsHandler(); |
74 |
|
75 |
/**
|
76 |
* This is the default constructor
|
77 |
*/
|
78 |
public JPasswordDlg() {
|
79 |
super();
|
80 |
initialize(); |
81 |
} |
82 |
|
83 |
class WindowEventsHandler extends WindowAdapter |
84 |
{ |
85 |
|
86 |
/* (non-Javadoc)
|
87 |
* @see java.awt.event.WindowAdapter#windowActivated(java.awt.event.WindowEvent)
|
88 |
*/
|
89 |
public void windowActivated(WindowEvent e) { |
90 |
// TODO Auto-generated method stub
|
91 |
super.windowActivated(e);
|
92 |
jPasswordField.requestFocus(); |
93 |
} |
94 |
|
95 |
} |
96 |
/**
|
97 |
* This method initializes this
|
98 |
*
|
99 |
* @return void
|
100 |
*/
|
101 |
private void initialize() { |
102 |
this.setSize(287, 172); |
103 |
this.setModal(true); |
104 |
this.setResizable(false); |
105 |
this.setTitle("Enter Password"); |
106 |
this.setContentPane(getJContentPane());
|
107 |
|
108 |
addWindowListener(windowHandler); |
109 |
} |
110 |
/**
|
111 |
* This method initializes jContentPane
|
112 |
*
|
113 |
* @return javax.swing.JPanel
|
114 |
*/
|
115 |
private JPanel getJContentPane() { |
116 |
if (jContentPane == null) { |
117 |
jContentPane = new JPanel(); |
118 |
jContentPane.setLayout(null);
|
119 |
jContentPane.add(getJButton1(), null);
|
120 |
jContentPane.add(getJButtonOK(), null);
|
121 |
jContentPane.add(getJPasswordField(), null);
|
122 |
jContentPane.add(getJLblMensaje(), null);
|
123 |
|
124 |
} |
125 |
return jContentPane;
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* This method initializes jButton
|
130 |
*
|
131 |
* @return javax.swing.JButton
|
132 |
*/
|
133 |
private JButton getJButtonOK() { |
134 |
if (jButtonOK == null) { |
135 |
jButtonOK = new JButton(); |
136 |
jButtonOK.setText("OK");
|
137 |
jButtonOK.setPreferredSize(new java.awt.Dimension(65, 23)); |
138 |
jButtonOK.setBounds(35, 110, 101, 22); |
139 |
jButtonOK.addActionListener(new java.awt.event.ActionListener() {
|
140 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
141 |
System.out.println("actionPerformed()"); // TODO |
142 |
// Auto-generated
|
143 |
// Event stub
|
144 |
// actionPerformed()
|
145 |
password = String.copyValueOf(getJPasswordField()
|
146 |
.getPassword()); |
147 |
dispose(); |
148 |
} |
149 |
}); |
150 |
} |
151 |
return jButtonOK;
|
152 |
} |
153 |
|
154 |
/**
|
155 |
* This method initializes jButton1
|
156 |
*
|
157 |
* @return javax.swing.JButton
|
158 |
*/
|
159 |
private JButton getJButton1() { |
160 |
if (jButton1 == null) { |
161 |
jButton1 = new JButton(); |
162 |
jButton1.setText("Cancel");
|
163 |
jButton1.setBounds(136, 110, 99, 22); |
164 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
165 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
166 |
password = null;
|
167 |
dispose(); |
168 |
} |
169 |
}); |
170 |
} |
171 |
return jButton1;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* This method initializes jPasswordField
|
176 |
*
|
177 |
* @return javax.swing.JPasswordField
|
178 |
*/
|
179 |
private JPasswordField getJPasswordField() { |
180 |
if (jPasswordField == null) { |
181 |
jPasswordField = new JPasswordField(); |
182 |
jPasswordField.setPreferredSize(new java.awt.Dimension(60, 22)); |
183 |
jPasswordField.setBounds(65, 78, 145, 21); |
184 |
jPasswordField.addKeyListener(new java.awt.event.KeyAdapter() {
|
185 |
public void keyTyped(java.awt.event.KeyEvent e) { |
186 |
if (e.getKeyChar() == KeyEvent.VK_ENTER) { |
187 |
// System.out.println("INTRO");
|
188 |
getJButtonOK().doClick(); |
189 |
} |
190 |
} |
191 |
}); |
192 |
} |
193 |
return jPasswordField;
|
194 |
} |
195 |
|
196 |
/**
|
197 |
* @return Returns the password.
|
198 |
*/
|
199 |
public String getPassword() { |
200 |
return password;
|
201 |
} |
202 |
|
203 |
public void setMessage(String str) { |
204 |
getJLblMensaje().setText(str); |
205 |
} |
206 |
|
207 |
/**
|
208 |
* This method initializes jEditorPane
|
209 |
*
|
210 |
* @return javax.swing.JEditorPane
|
211 |
*/
|
212 |
private JEditorPane getJEditorPane() { |
213 |
if (jEditorPane == null) { |
214 |
jEditorPane = new JEditorPane(); |
215 |
} |
216 |
return jEditorPane;
|
217 |
} |
218 |
|
219 |
/**
|
220 |
* This method initializes jTextArea
|
221 |
*
|
222 |
* @return javax.swing.JTextArea
|
223 |
*/
|
224 |
private JTextArea getJLblMensaje() { |
225 |
if (jLblMensaje == null) { |
226 |
jLblMensaje = new JTextArea(); |
227 |
jLblMensaje.setEditable(false);
|
228 |
jLblMensaje.setForeground(java.awt.Color.black); |
229 |
jLblMensaje.setBackground(java.awt.SystemColor.control); |
230 |
jLblMensaje.setText("Mensaje");
|
231 |
jLblMensaje.setLineWrap(true);
|
232 |
jLblMensaje.setFont(new java.awt.Font("SansSerif", |
233 |
java.awt.Font.PLAIN, 12));
|
234 |
jLblMensaje.setPreferredSize(new java.awt.Dimension(270, 50)); |
235 |
jLblMensaje.setBounds(9, 6, 266, 68); |
236 |
jLblMensaje.setWrapStyleWord(true);
|
237 |
} |
238 |
return jLblMensaje;
|
239 |
} |
240 |
} // @jve:decl-index=0:visual-constraint="10,10"
|