KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > authentication > gui > LoginUsernamePasswordPanel


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.authentication.gui;
20
21 import java.awt.Component JavaDoc;
22 import java.awt.Container JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.awt.Font JavaDoc;
25 import java.awt.LayoutManager JavaDoc;
26
27 import javax.swing.JLabel JavaDoc;
28 import javax.swing.JPanel JavaDoc;
29 import javax.swing.JPasswordField JavaDoc;
30 import javax.swing.JTextField JavaDoc;
31
32 /**
33  * Data entry panel for the login dialog.
34  *
35  * @author Matthew Large
36  * @version $Revision: 1.1 $
37  *
38  */

39 public class LoginUsernamePasswordPanel extends JPanel JavaDoc implements LayoutManager JavaDoc {
40
41     /**
42      * Label for the username field.
43      */

44     private JLabel JavaDoc m_usernameLabel = null;
45     
46     /**
47      * Label for the password field.
48      */

49     private JLabel JavaDoc m_passwordLabel = null;
50     
51     /**
52      * Username field.
53      */

54     private JTextField JavaDoc m_username = null;
55     
56     /**
57      * Password field.
58      */

59     private JPasswordField JavaDoc m_password = null;
60     
61     /**
62      * Constructs a new data entry panel.
63      *
64      * @param dialog Login dialog that this panel will be part of
65      */

66     public LoginUsernamePasswordPanel(LoginDialog dialog) {
67         super();
68         this.setup(dialog);
69     }
70     
71     /**
72      * Configures this entry panel.
73      *
74      * @param dialog Login dialog that this panel will be part of
75      */

76     private void setup(LoginDialog dialog) {
77         this.setLayout(this);
78         
79         String JavaDoc fontName = "Dialog";
80         int fontSize = 11;
81         Font JavaDoc font = new Font JavaDoc(fontName, Font.PLAIN, fontSize);
82         
83         m_usernameLabel = new JLabel JavaDoc("User name");
84         m_usernameLabel.setFont(font);
85         this.add(m_usernameLabel);
86         
87         m_passwordLabel = new JLabel JavaDoc("Password");
88         m_passwordLabel.setFont(font);
89         this.add(m_passwordLabel);
90
91         m_username = new JTextField JavaDoc();
92         m_username.addKeyListener(dialog);
93         this.add(m_username);
94         m_password = new JPasswordField JavaDoc();
95         m_password.addKeyListener(dialog);
96         this.add(m_password);
97     }
98
99     /**
100      * @param arg0
101      */

102     private LoginUsernamePasswordPanel(boolean arg0) {
103         super(arg0);
104     }
105
106     /**
107      * @param arg0
108      */

109     private LoginUsernamePasswordPanel(LayoutManager JavaDoc arg0) {
110         super(arg0);
111     }
112
113     /**
114      * @param arg0
115      * @param arg1
116      */

117     private LoginUsernamePasswordPanel(LayoutManager JavaDoc arg0, boolean arg1) {
118         super(arg0, arg1);
119     }
120
121     /* (non-Javadoc)
122      * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
123      */

124     public void removeLayoutComponent(Component JavaDoc arg0) {
125
126     }
127
128     /* (non-Javadoc)
129      * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
130      */

131     public void layoutContainer(Container JavaDoc arg0) {
132         
133         m_usernameLabel.setLocation(20,50);
134         m_usernameLabel.setSize(60,20);
135         
136         m_passwordLabel.setLocation(20,100);
137         m_passwordLabel.setSize(60,20);
138         
139         m_username.setLocation(100, 50);
140         m_username.setSize(350,20);
141         m_password.setLocation(100, 100);
142         m_password.setSize(350,20);
143     }
144     
145     /**
146      * Returns the username.
147      *
148      * @return Username
149      */

150     public String JavaDoc getUsername() {
151         return this.m_username.getText();
152     }
153     
154     /**
155      * Sets the username, pre-populates the username field.
156      *
157      * @param sUsername Username
158      */

159     public void setUsername(String JavaDoc sUsername) {
160         this.m_username.setText(sUsername);
161     }
162     
163     /**
164      * Returns the password.
165      *
166      * @return Password
167      */

168     public String JavaDoc getPassword() {
169         return this.m_password.getText();
170     }
171
172     /**
173      * Sets the password, pre-populates the password field.
174      *
175      * @param sPassword Password
176      */

177     public void setPassword(String JavaDoc sPassword) {
178         this.m_password.setText(sPassword);
179     }
180
181     /* (non-Javadoc)
182      * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
183      */

184     public void addLayoutComponent(String JavaDoc arg0, Component JavaDoc arg1) {
185
186     }
187
188     /* (non-Javadoc)
189      * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
190      */

191     public Dimension JavaDoc minimumLayoutSize(Container JavaDoc arg0) {
192         return this.getPreferredSize();
193     }
194
195     /* (non-Javadoc)
196      * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
197      */

198     public Dimension JavaDoc preferredLayoutSize(Container JavaDoc arg0) {
199         return this.getPreferredSize();
200     }
201     
202     
203
204 }
205
Popular Tags