root / tags / v1_0_2_Build_915 / libraries / libIverUtiles / src / com / iver / utiles / swing / JPasswordDlg.java @ 12217
History | View | Annotate | Download (6.88 KB)
1 | 3080 | fjp | /*
|
---|---|---|---|
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 | 3440 | fjp | import java.awt.event.WindowAdapter; |
48 | import java.awt.event.WindowEvent; |
||
49 | 3080 | fjp | |
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 | 3440 | fjp | |
61 | 3080 | fjp | private JButton jButtonOK = null; |
62 | 3440 | fjp | |
63 | 3080 | fjp | private JButton jButton1 = null; |
64 | 3440 | fjp | |
65 | 3080 | fjp | private JPasswordField jPasswordField = null; |
66 | 3440 | fjp | |
67 | 3080 | fjp | private String password = null; |
68 | 3440 | fjp | |
69 | 3080 | fjp | private JEditorPane jEditorPane = null; |
70 | 3440 | fjp | |
71 | 3080 | fjp | private JTextArea jLblMensaje = null; |
72 | 3440 | fjp | |
73 | private WindowEventsHandler windowHandler = new WindowEventsHandler(); |
||
74 | 3080 | fjp | |
75 | /**
|
||
76 | * This is the default constructor
|
||
77 | */
|
||
78 | public JPasswordDlg() {
|
||
79 | super();
|
||
80 | initialize(); |
||
81 | } |
||
82 | |||
83 | 3440 | fjp | 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 | 3080 | fjp | /**
|
97 | * This method initializes this
|
||
98 | *
|
||
99 | * @return void
|
||
100 | */
|
||
101 | 3440 | fjp | private void initialize() { |
102 | 3080 | fjp | this.setSize(287, 172); |
103 | this.setModal(true); |
||
104 | this.setResizable(false); |
||
105 | this.setTitle("Enter Password"); |
||
106 | this.setContentPane(getJContentPane());
|
||
107 | 3440 | fjp | |
108 | addWindowListener(windowHandler); |
||
109 | 3080 | fjp | } |
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 | 3440 | fjp | |
124 | 3080 | fjp | } |
125 | return jContentPane;
|
||
126 | } |
||
127 | |||
128 | /**
|
||
129 | 3440 | fjp | * This method initializes jButton
|
130 | *
|
||
131 | * @return javax.swing.JButton
|
||
132 | */
|
||
133 | 3080 | fjp | private JButton getJButtonOK() { |
134 | 3440 | fjp | 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 | 3080 | fjp | dispose(); |
148 | 3440 | fjp | } |
149 | }); |
||
150 | } |
||
151 | return jButtonOK;
|
||
152 | 3080 | fjp | } |
153 | |||
154 | /**
|
||
155 | 3440 | fjp | * This method initializes jButton1
|
156 | *
|
||
157 | * @return javax.swing.JButton
|
||
158 | */
|
||
159 | 3080 | fjp | private JButton getJButton1() { |
160 | 3440 | fjp | 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 | 3080 | fjp | dispose(); |
168 | 3440 | fjp | } |
169 | }); |
||
170 | } |
||
171 | return jButton1;
|
||
172 | 3080 | fjp | } |
173 | |||
174 | /**
|
||
175 | 3440 | fjp | * This method initializes jPasswordField
|
176 | *
|
||
177 | * @return javax.swing.JPasswordField
|
||
178 | */
|
||
179 | 3080 | fjp | private JPasswordField getJPasswordField() { |
180 | 3440 | fjp | 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 | 3080 | fjp | // System.out.println("INTRO");
|
188 | getJButtonOK().doClick(); |
||
189 | } |
||
190 | 3440 | fjp | } |
191 | }); |
||
192 | } |
||
193 | return jPasswordField;
|
||
194 | 3080 | fjp | } |
195 | |||
196 | /**
|
||
197 | * @return Returns the password.
|
||
198 | */
|
||
199 | public String getPassword() { |
||
200 | return password;
|
||
201 | } |
||
202 | |||
203 | 3440 | fjp | public void setMessage(String str) { |
204 | 3080 | fjp | getJLblMensaje().setText(str); |
205 | } |
||
206 | |||
207 | /**
|
||
208 | 3440 | fjp | * This method initializes jEditorPane
|
209 | *
|
||
210 | * @return javax.swing.JEditorPane
|
||
211 | */
|
||
212 | 3080 | fjp | private JEditorPane getJEditorPane() { |
213 | 3440 | fjp | if (jEditorPane == null) { |
214 | jEditorPane = new JEditorPane(); |
||
215 | } |
||
216 | return jEditorPane;
|
||
217 | 3080 | fjp | } |
218 | |||
219 | /**
|
||
220 | 3440 | fjp | * This method initializes jTextArea
|
221 | *
|
||
222 | * @return javax.swing.JTextArea
|
||
223 | */
|
||
224 | 3080 | fjp | private JTextArea getJLblMensaje() { |
225 | 3440 | fjp | 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 | 3080 | fjp | } |
240 | 3440 | fjp | } // @jve:decl-index=0:visual-constraint="10,10" |