KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > j2ee > ui > AddInstanceVisualNamePasswordPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.j2ee.sun.ide.j2ee.ui;
20
21 import java.util.HashSet JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.Set JavaDoc;
24 import javax.swing.JPanel JavaDoc;
25 import javax.swing.event.ChangeEvent JavaDoc;
26 import javax.swing.event.ChangeListener JavaDoc;
27 import javax.swing.event.DocumentEvent JavaDoc;
28 import javax.swing.event.DocumentListener JavaDoc;
29 import org.openide.util.NbBundle;
30
31 public final class AddInstanceVisualNamePasswordPanel extends JPanel JavaDoc {
32
33     /**
34      * Creates new form AddInstanceVisualNamePasswordPanel
35      */

36     public AddInstanceVisualNamePasswordPanel() {
37         initComponents();
38         DocumentListener JavaDoc l = new MyDocListener();
39         adminName.getDocument().addDocumentListener(l);
40         adminPassword.getDocument().addDocumentListener(l);
41     }
42
43     public String JavaDoc getName() {
44         return NbBundle.getMessage(AddInstanceVisualNamePasswordPanel.class,
45                 "StepName_EnterAdminLoginInfo"); // NOI18N
46
}
47     
48     void setUName(String JavaDoc uname) {
49         adminName.setText(uname);
50     }
51     
52     String JavaDoc getUName() {
53         return adminName.getText();
54     }
55     
56     void setPWord(String JavaDoc pw) {
57         adminPassword.setText(pw);
58     }
59
60     String JavaDoc getPWord() {
61         return new String JavaDoc(adminPassword.getPassword());
62     }
63     
64     // Event Handler
65
//
66
private Set JavaDoc/*<ChangeListener.*/ listenrs = new HashSet JavaDoc/*<Changelisteners.*/();
67
68     void addChangeListener(ChangeListener JavaDoc l) {
69         synchronized (listenrs) {
70             listenrs.add(l);
71         }
72     }
73     
74     void removeChangeListener(ChangeListener JavaDoc l ) {
75         synchronized (listenrs) {
76             listenrs.remove(l);
77         }
78     }
79
80     private void fireChangeEvent() {
81         Iterator JavaDoc it;
82         synchronized (listenrs) {
83             it = new HashSet JavaDoc(listenrs).iterator();
84         }
85         ChangeEvent JavaDoc ev = new ChangeEvent JavaDoc(this);
86         while (it.hasNext()) {
87             ((ChangeListener JavaDoc)it.next()).stateChanged (ev);
88         }
89     }
90     
91     class MyDocListener implements DocumentListener JavaDoc {
92         public void insertUpdate(DocumentEvent JavaDoc e) {
93             fireChangeEvent();
94         }
95
96         public void removeUpdate(DocumentEvent JavaDoc e) {
97             fireChangeEvent();
98         }
99
100         public void changedUpdate(DocumentEvent JavaDoc e) {
101             fireChangeEvent();
102         }
103         
104     }
105
106     /** This method is called from within the constructor to
107      * initialize the form.
108      * WARNING: Do NOT modify this code. The content of this method is
109      * always regenerated by the Form Editor.
110      */

111     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
112
private void initComponents() {
113         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
114
115         jLabel1 = new javax.swing.JLabel JavaDoc();
116         description = new javax.swing.JLabel JavaDoc();
117         adminNameLabel = new javax.swing.JLabel JavaDoc();
118         adminName = new javax.swing.JTextField JavaDoc();
119         adminPasswordLabel = new javax.swing.JLabel JavaDoc();
120         adminPassword = new javax.swing.JPasswordField JavaDoc();
121         warning = new javax.swing.JLabel JavaDoc();
122         spacingHack = new javax.swing.JLabel JavaDoc();
123
124         jLabel1.setText("jLabel1");
125
126         setLayout(new java.awt.GridBagLayout JavaDoc());
127
128         java.util.ResourceBundle JavaDoc bundle = java.util.ResourceBundle.getBundle("org/netbeans/modules/j2ee/sun/ide/j2ee/ui/Bundle"); // NOI18N
129
description.setText(bundle.getString("TXT_namePasswordDescription")); // NOI18N
130
description.setFocusable(false);
131         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
132         gridBagConstraints.gridwidth = 2;
133         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
134         gridBagConstraints.weightx = 1.0;
135         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 0);
136         add(description, gridBagConstraints);
137
138         adminNameLabel.setLabelFor(adminName);
139         org.openide.awt.Mnemonics.setLocalizedText(adminNameLabel, org.openide.util.NbBundle.getMessage(AddInstanceVisualNamePasswordPanel.class, "LBL_adminNameLabel")); // NOI18N
140
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
141         gridBagConstraints.gridx = 0;
142         gridBagConstraints.gridy = 1;
143         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
144         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 5, 6);
145         add(adminNameLabel, gridBagConstraints);
146
147         adminName.setText(org.openide.util.NbBundle.getMessage(AddInstanceVisualNamePasswordPanel.class, "VAL_adminName_NOI18N")); // NOI18N
148
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.gridx = 1;
150         gridBagConstraints.gridy = 1;
151         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
152         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
153         add(adminName, gridBagConstraints);
154         adminName.getAccessibleContext().setAccessibleDescription(bundle.getString("DSC_adminName")); // NOI18N
155

156         adminPasswordLabel.setLabelFor(adminPassword);
157         org.openide.awt.Mnemonics.setLocalizedText(adminPasswordLabel, org.openide.util.NbBundle.getMessage(AddInstanceVisualNamePasswordPanel.class, "LBL_adminPasswordLabel")); // NOI18N
158
gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
159         gridBagConstraints.gridx = 0;
160         gridBagConstraints.gridy = 2;
161         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
162         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 5, 6);
163         add(adminPasswordLabel, gridBagConstraints);
164
165         adminPassword.setColumns(10);
166         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
167         gridBagConstraints.gridx = 1;
168         gridBagConstraints.gridy = 2;
169         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
170         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 6, 0, 0);
171         add(adminPassword, gridBagConstraints);
172         adminPassword.getAccessibleContext().setAccessibleDescription(bundle.getString("DSC_adminPassword")); // NOI18N
173

174         warning.setText(bundle.getString("TXT_namePasswordWarning")); // NOI18N
175
warning.setFocusable(false);
176         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
177         gridBagConstraints.gridx = 0;
178         gridBagConstraints.gridy = 3;
179         gridBagConstraints.gridwidth = 2;
180         gridBagConstraints.gridheight = 2;
181         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
182         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
183         add(warning, gridBagConstraints);
184
185         spacingHack.setEnabled(false);
186         spacingHack.setFocusable(false);
187         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
188         gridBagConstraints.gridx = 0;
189         gridBagConstraints.gridy = 5;
190         gridBagConstraints.weighty = 1.0;
191         add(spacingHack, gridBagConstraints);
192     }// </editor-fold>//GEN-END:initComponents
193

194
195     // Variables declaration - do not modify//GEN-BEGIN:variables
196
private javax.swing.JTextField JavaDoc adminName;
197     private javax.swing.JLabel JavaDoc adminNameLabel;
198     private javax.swing.JPasswordField JavaDoc adminPassword;
199     private javax.swing.JLabel JavaDoc adminPasswordLabel;
200     private javax.swing.JLabel JavaDoc description;
201     private javax.swing.JLabel JavaDoc jLabel1;
202     private javax.swing.JLabel JavaDoc spacingHack;
203     private javax.swing.JLabel JavaDoc warning;
204     // End of variables declaration//GEN-END:variables
205

206 }
207
208
Popular Tags