001: /*
002: #IFNDEF ALT_LICENSE
003: ThinWire(R) RIA Ajax Framework
004: Copyright (C) 2003-2007 Custom Credit Systems
005:
006: This library is free software; you can redistribute it and/or modify it under
007: the terms of the GNU Lesser General Public License as published by the Free
008: Software Foundation; either version 2.1 of the License, or (at your option) any
009: later version.
010:
011: This library is distributed in the hope that it will be useful, but WITHOUT ANY
012: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013: PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015: You should have received a copy of the GNU Lesser General Public License along
016: with this library; if not, write to the Free Software Foundation, Inc., 59
017: Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019: Users who would rather have a commercial license, warranty or support should
020: contact the following company who invented, built and supports the technology:
021:
022: Custom Credit Systems, Richardson, TX 75081, USA.
023: email: info@thinwire.com ph: +1 (888) 644-6405
024: http://www.thinwire.com
025: #ENDIF
026: [ v1.2_RC2 ]
027: */
028: package thinwire.ui;
029:
030: /**
031: * This is a text field screen element.
032: * <p>
033: * <p>
034: * <b>Example:</b> <br>
035: * <img src="doc-files/TextField-1.png"> <br>
036: *
037: * <pre>
038: * Dialog dlg = new Dialog("TextField Test");
039: * dlg.setBounds(25, 25, 450, 100);
040: *
041: * final TextField tf = new TextField();
042: * tf.setBounds(25, 25, 150, 20);
043: *
044: * Button btn = new Button("Numeric Mask ###.##");
045: * btn.setBounds(200, 20, 150, 30);
046: *
047: * btn.addActionListener(Button.ACTION_CLICK, new ActionListener() {
048: * public void actionPerformed(ActionEvent ev) {
049: * tf.setEditMask("###.##");
050: * tf.setFocus(true);
051: * }
052: * });
053: *
054: * dlg.getChildren().add(tf);
055: * dlg.getChildren().add(btn);
056: * dlg.setVisible(true);
057: * </pre>
058: *
059: * </p>
060: * <p>
061: * <b>Keyboard Navigation:</b><br>
062: * <table border="1">
063: * <tr>
064: * <td>KEY</td>
065: * <td>RESPONSE</td>
066: * <td>NOTE</td>
067: * </tr>
068: * </table>
069: * </p>
070: * <UL>
071: * <LI>There's no need to set both a maxLength property and an editMask.
072: * <LI>If they conflict - e.g. the maxLength value is different from the length
073: * of the editMask - the minimum of the 2 will be used in validation.
074: * <LI>Setting maxLength to a value k is equivalent to setting an edit mask of
075: * k occurrences of 'x' - the anything goes mask character.
076: * </UL>
077: *
078: * @author Joshua J. Gertzen
079: */
080: public class TextField extends AbstractMaskEditorComponent {
081: public static final String PROPERTY_INPUT_HIDDEN = "inputHidden";
082:
083: private boolean inputHidden = false;
084:
085: /**
086: * Constructs a new TextField with no text.
087: */
088: public TextField() {
089:
090: }
091:
092: /**
093: * Constructs a new TextField with the specified text.
094: * @param text the text to display in the the TextField.
095: */
096: public TextField(String text) {
097: setText(text);
098: }
099:
100: public void setText(String text) {
101: formattedText = text = text == null ? "" : text;
102: super .setText(getUnformattedText(text));
103: }
104:
105: /**
106: * Returns whether the input is hidden (as in a password field).
107: * @return true if the input should be hidden
108: */
109: public boolean isInputHidden() {
110: return inputHidden;
111: }
112:
113: /**
114: * Hides the text typed into the field with asterisks (as in a password field).
115: * @param inputHidden (Default = false)
116: */
117: public void setInputHidden(boolean inputHidden) {
118: boolean oldInputHidden = this.inputHidden;
119: this.inputHidden = inputHidden;
120: firePropertyChange(this, PROPERTY_INPUT_HIDDEN, oldInputHidden,
121: inputHidden);
122: }
123: }
|