01: package com.xoetrope.swing;
02:
03: import net.xoetrope.swing.XButton;
04: import net.xoetrope.swing.XDialog;
05: import net.xoetrope.swing.XLabel;
06: import net.xoetrope.swing.XPassword;
07: import net.xoetrope.xui.style.XStyleFactory;
08:
09: /**
10: * A dialog with an input for a password string, this class is designed for use with
11: * the date edit and is not intended for general use. See the XUI tutorial and
12: * knowledge base for further examples of creating a password dialog
13: *
14: * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
15: * the GNU Public License (GPL), please see license.txt for more details. If
16: * you make commercial use of this software you must purchase a commercial
17: * license from Xoetrope.</p>
18: * <p> $Revision: 1.7 $</p>
19: */
20: public class XPasswordDlg extends XDialog {
21: XPassword passwordField;
22: XButton okBtn, cancelBtn;
23: XLabel passwordLabel;
24:
25: /**
26: * Create a new password dialog
27: */
28: public XPasswordDlg() {
29: super (true, 2);
30:
31: setSize(325, 80);
32: setCaption(translate("Password Input"));
33:
34: okBtn = (XButton) pageHelper.componentFactory.addComponent(
35: "Button", 210, 40, 100, 25, translate("OK"), "XButton");
36: cancelBtn = (XButton) pageHelper.componentFactory.addComponent(
37: "Button", 100, 40, 100, 25, translate("Cancel"),
38: "XButton");
39:
40: XStyleFactory styleFactory = (XStyleFactory) pageHelper.componentFactory;
41: passwordLabel = (XLabel) styleFactory.addComponent("Label", 10,
42: 10, 88, 20, translate("Password"), null);
43: passwordField = (XPassword) styleFactory.addComponent(
44: "Password", 100, 10, 211, 20, translate("Password"),
45: null);
46: passwordField.setEchoChar('*');
47:
48: getEventHandler().addHandler(this , cancelBtn, "ActionHandler",
49: "closeDlg");
50: getEventHandler().addHandler(this , okBtn, "ActionHandler",
51: "okClicked");
52:
53: setUseNativeHeaders(true);
54: }
55:
56: /**
57: * Close the dialog when the OK button is clicked
58: */
59: public void okClicked() {
60: super .closeDlg();
61: }
62:
63: /**
64: * Close the dialog when the Cancel button is clicked and clear the password field
65: */
66: public void closeDlg() {
67: passwordField.setText("");
68: super .closeDlg();
69: }
70:
71: /**
72: * Get the passord text
73: * @return the password
74: */
75: public String getPassword() {
76: return passwordField.getText();
77: }
78: }
|