001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.authentication.gui;
020:
021: import java.awt.Component;
022: import java.awt.Container;
023: import java.awt.Dimension;
024: import java.awt.Font;
025: import java.awt.LayoutManager;
026:
027: import javax.swing.JLabel;
028: import javax.swing.JPanel;
029: import javax.swing.JPasswordField;
030: import javax.swing.JTextField;
031:
032: /**
033: * Data entry panel for the login dialog.
034: *
035: * @author Matthew Large
036: * @version $Revision: 1.1 $
037: *
038: */
039: public class LoginUsernamePasswordPanel extends JPanel implements
040: LayoutManager {
041:
042: /**
043: * Label for the username field.
044: */
045: private JLabel m_usernameLabel = null;
046:
047: /**
048: * Label for the password field.
049: */
050: private JLabel m_passwordLabel = null;
051:
052: /**
053: * Username field.
054: */
055: private JTextField m_username = null;
056:
057: /**
058: * Password field.
059: */
060: private JPasswordField m_password = null;
061:
062: /**
063: * Constructs a new data entry panel.
064: *
065: * @param dialog Login dialog that this panel will be part of
066: */
067: public LoginUsernamePasswordPanel(LoginDialog dialog) {
068: super ();
069: this .setup(dialog);
070: }
071:
072: /**
073: * Configures this entry panel.
074: *
075: * @param dialog Login dialog that this panel will be part of
076: */
077: private void setup(LoginDialog dialog) {
078: this .setLayout(this );
079:
080: String fontName = "Dialog";
081: int fontSize = 11;
082: Font font = new Font(fontName, Font.PLAIN, fontSize);
083:
084: m_usernameLabel = new JLabel("User name");
085: m_usernameLabel.setFont(font);
086: this .add(m_usernameLabel);
087:
088: m_passwordLabel = new JLabel("Password");
089: m_passwordLabel.setFont(font);
090: this .add(m_passwordLabel);
091:
092: m_username = new JTextField();
093: m_username.addKeyListener(dialog);
094: this .add(m_username);
095: m_password = new JPasswordField();
096: m_password.addKeyListener(dialog);
097: this .add(m_password);
098: }
099:
100: /**
101: * @param arg0
102: */
103: private LoginUsernamePasswordPanel(boolean arg0) {
104: super (arg0);
105: }
106:
107: /**
108: * @param arg0
109: */
110: private LoginUsernamePasswordPanel(LayoutManager arg0) {
111: super (arg0);
112: }
113:
114: /**
115: * @param arg0
116: * @param arg1
117: */
118: private LoginUsernamePasswordPanel(LayoutManager arg0, boolean arg1) {
119: super (arg0, arg1);
120: }
121:
122: /* (non-Javadoc)
123: * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
124: */
125: public void removeLayoutComponent(Component arg0) {
126:
127: }
128:
129: /* (non-Javadoc)
130: * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
131: */
132: public void layoutContainer(Container arg0) {
133:
134: m_usernameLabel.setLocation(20, 50);
135: m_usernameLabel.setSize(60, 20);
136:
137: m_passwordLabel.setLocation(20, 100);
138: m_passwordLabel.setSize(60, 20);
139:
140: m_username.setLocation(100, 50);
141: m_username.setSize(350, 20);
142: m_password.setLocation(100, 100);
143: m_password.setSize(350, 20);
144: }
145:
146: /**
147: * Returns the username.
148: *
149: * @return Username
150: */
151: public String getUsername() {
152: return this .m_username.getText();
153: }
154:
155: /**
156: * Sets the username, pre-populates the username field.
157: *
158: * @param sUsername Username
159: */
160: public void setUsername(String sUsername) {
161: this .m_username.setText(sUsername);
162: }
163:
164: /**
165: * Returns the password.
166: *
167: * @return Password
168: */
169: public String getPassword() {
170: return this .m_password.getText();
171: }
172:
173: /**
174: * Sets the password, pre-populates the password field.
175: *
176: * @param sPassword Password
177: */
178: public void setPassword(String sPassword) {
179: this .m_password.setText(sPassword);
180: }
181:
182: /* (non-Javadoc)
183: * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
184: */
185: public void addLayoutComponent(String arg0, Component arg1) {
186:
187: }
188:
189: /* (non-Javadoc)
190: * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
191: */
192: public Dimension minimumLayoutSize(Container arg0) {
193: return this .getPreferredSize();
194: }
195:
196: /* (non-Javadoc)
197: * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
198: */
199: public Dimension preferredLayoutSize(Container arg0) {
200: return this.getPreferredSize();
201: }
202:
203: }
|