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 NameProperty TypeDescription
MaskString Editing mask.
TextString Editing text.

See Also:
TextEdit

Constructor Index

 o MaskText()
Construct an empty MaskText.
 o MaskText(int)
Construct a MaskText with cols columns.
 o MaskText(String)
Construct a MaskText with ms as the initial mask.

Method Index

 o getMask()
Get the editing mask.
 o getText()
Return the text value of the MaskText.
 o processKeyEvent(KeyEvent)
Handle key input.
 o processMouseEvent(MouseEvent)
Make sure the cursor is never out of the picture area.
 o setMask(Mask)
Set a new mask.
 o setMask(String)
Set a new mask.
 o setText(String)
Set the text value to the supplied string.

Constructors

 o MaskText
 public MaskText()
Construct an empty MaskText. You must call setMask to set the editing mask.

 o MaskText
 public MaskText(int cols)
Construct a MaskText with cols columns.

Parameters:
cols - number of columns.
 o MaskText
 public MaskText(String ms)
Construct a MaskText with ms as the initial mask.

Parameters:
ms - text mask.

Methods

 o setMask
 public synchronized void setMask(String ms)
Set a new mask.

Parameters:
ms - text mask.
 o setMask
 public synchronized void setMask(Mask ms)
Set a new mask.

Parameters:
ms - Mask object.
 o getMask
 public Mask getMask()
Get the editing mask.

Returns:
mask object.
 o 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
 o 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
 o 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
 o 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