Class tea.set.MaskText
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));
- See Also:
- TextEdit
-
MaskText(int)
- Construct a MaskText with cols columns.
-
MaskText(String)
- Construct a MaskText with ms as the initial mask.
-
getText()
- Return the text value of the MaskText.
-
keyDown(Event, int)
- Handle key input.
-
mouseUp(Event, int, int)
- Make sure the cursor is never out of the picture area.
-
setMask(String)
- Set a new mask.
-
setText(String)
- Set the text value to the supplied string.
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 void setMask(String ms)
- Set a new mask.
- Parameters:
- ms - text mask.
setText
public 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
mouseUp
public boolean mouseUp(Event e,
int x,
int y)
- 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:
- mouseUp in class Cell
keyDown
public boolean keyDown(Event e,
int key)
- Handle key input.
- Parameters:
- e - event object.
- key - key pressed.
- Overrides:
- keyDown in class Cell
All Packages Class Hierarchy This Package Previous Next Index