All Packages Class Hierarchy This Package Previous Next Index
Class tea.set.MaskText
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----tea.set.Cell
|
+----tea.set.MaskText
- public class MaskText
- extends Cell
MaskText is a template based text field.
It supports an input mask/template. Through
the input mask, a template can be defined.
Each template can have one or more fields, each defined by a picture
specification. User can only edit characters in the fields. Other
text in the template remain static. The values in the
template fields are checked at runtime. The format used to define the
template is described below.
Mask can be defined using the following code, similar to PL/I picture:
- \
- character, remove the special meaning of [ and ]
- c
- alphabet, lower case
- C
- alphabet, upper case
- A
- alphabet (c || C) and space
- ,
- (, . ' " ; : / ? !)
- 9
- * V - digits or decimal points
- S
- digit, space, and punctuation
- X
- character
Each mask can contain one or many pictures enclosed in bracket:
ex. "Name: [CAAAAAAAAAAAA] Tel: [999]-[999]-[9999]"
MaskText itself does not draw a border around the text area. Use
Effect3D to add a border if desired:
add(new Effect3D(new MaskText(mask), Effect3D.LOWERED));
MaskText supports the following properties:
Property Name | Property Type | Description |
Mask | String |
Editing mask. |
Text | String |
Editing text. |
- See Also:
- TextEdit
-
MaskText()
- Construct an empty MaskText.
-
MaskText(int)
- Construct a MaskText with cols columns.
-
MaskText(String)
- Construct a MaskText with ms as the initial mask.
-
getMask()
- Get the editing mask.
-
getText()
- Return the text value of the MaskText.
-
processKeyEvent(KeyEvent)
- Handle key input.
-
processMouseEvent(MouseEvent)
- Make sure the cursor is never out of the picture area.
-
setMask(Mask)
- Set a new mask.
-
setMask(String)
- Set a new mask.
-
setText(String)
- Set the text value to the supplied string.
MaskText
public MaskText()
- Construct an empty MaskText. You must call setMask to set the editing
mask.
MaskText
public MaskText(int cols)
- Construct a MaskText with cols columns.
- Parameters:
- cols - number of columns.
MaskText
public MaskText(String ms)
- Construct a MaskText with ms as the initial mask.
- Parameters:
- ms - text mask.
setMask
public synchronized void setMask(String ms)
- Set a new mask.
- Parameters:
- ms - text mask.
setMask
public synchronized void setMask(Mask ms)
- Set a new mask.
- Parameters:
- ms - Mask object.
getMask
public Mask getMask()
- Get the editing mask.
- Returns:
- mask object.
setText
public synchronized void setText(String txt)
- Set the text value to the supplied string. The string is not
verified to see if it fits the template. It's the caller's
responsibility to ensure the value does not conflict with
the template. It's always safe to pass in a value returned
from MaskText.getText().
- Parameters:
- txt - cell text.
- Overrides:
- setText in class Cell
getText
public String getText()
- Return the text value of the MaskText. The return value is not
exactly what's shown on the screen. Space characters are
displayed as _ on screen, but they are returned as space char
from getText().
- Returns:
- cell text.
- Overrides:
- getText in class Cell
processMouseEvent
public void processMouseEvent(MouseEvent e)
- Make sure the cursor is never out of the picture area.
- Parameters:
- e - event object.
- x - x coordinate of mouse click.
- y - y coordinate of mouse click.
- Overrides:
- processMouseEvent in class Cell
processKeyEvent
public void processKeyEvent(KeyEvent e)
- Handle key input.
- Parameters:
- e - event object.
- key - key pressed.
- Overrides:
- processKeyEvent in class Cell
All Packages Class Hierarchy This Package Previous Next Index