01: package net.xoetrope.swing;
02:
03: import javax.swing.JTextField;
04:
05: import net.xoetrope.xui.XTextHolder;
06: import javax.swing.JPasswordField;
07: import net.xoetrope.xui.XAttributedComponent;
08:
09: /**
10: * <p>A wrapper for the Swing JPasswordField class, adding an echo character</p>
11: * <p>Copyright (c) Xoetrope Ltd., 1998-2004<br>
12: * License: see license.txt
13: * $Revision: 1.5 $
14: */
15: public class XPassword extends JPasswordField implements XTextHolder,
16: XAttributedComponent {
17: public XPassword() {
18: }
19:
20: /**
21: * Set one or more attributes of the component. Currently this handles the
22: * attributes
23: * @param attribName the attribute name
24: * @param attribValue the attribute value
25: * <OL>
26: * <LI>alignment, values=left|right|center|leading|trailing</LI>
27: * </OL>
28: */
29: public void setAttribute(String attribName, String attribValue) {
30: if (attribName.toLowerCase().compareTo("alignment") == 0)
31: setHorizontalAlignment(XAlignmentHelper
32: .getAlignmentOption(attribValue));
33: }
34:
35: public String getText() {
36: return new String(getPassword());
37: }
38: }
|