Class pvWinJ.PVMask
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Canvas
|
+----pvWinJ.PVEdit
|
+----pvWinJ.PVMask
- public class PVMask
- extends PVEdit
Class PVMask is designed to display and edit a text string
with entry validation specified by the mask.
There are three types of the entry validation:
[&] - a digit is expected
[@] - a letter of a Space is expected
[*] - any printable character is expected
It inherits edit mode behavior and painting styles from the
PVEdit.
All aspects of painting and edit mode behavior can be customized
through get/setProperty().
Example to insert an instance of the PVMask class in an applet
and set some properties:
public void init()
{
resize(580, 400);
setLayout(null);
PVMask mask = new PVMask("###) ###-#### Ext. ###");
mask.setBackColor(Color.yellow);
mask.setForeground(Color.red);
mask.setText3D(new Dimension(1, 0));
add(mask);
// note: the reshape() is the Component class method
date.setBounds(5, 10, 150, 25);
...
}
Notes:
Use the get/setBackgroundColor() to get/set background color
rather than the get/setBackground() methods.
When fontStyle is set to a LED.., then text is painted by the LED
build in font rather then the selected Font object.
PVMask()
- Constructor.
PVMask(String)
- Constructor.
getEditablePartOfText()
- Get a text string for the editable part of the PVMask.
getEscapeChar()
- Get the character that disables mask flag-characters (#,
getMask()
- Get mask string.
getPromptChar()
- Get the character that replaces not filled mask character
positions while editing text.
getText()
- Get full text string.
setEditablePartOfText(String)
- Set a text string for the editable part of the PVMask.
setEscapeChar(char)
- Set the character that disables mask flag-characters (#,
setMask(String)
- Set mask string.
setPromptChar(char)
- Set the character that replaces not filled mask character
positions while editing text.
setText(String)
-
PVMask
public PVMask(String mask)
- Constructor.
- Parameters:
- mask - text string that represents mask. Other
properties are set:
editablePartOfText - ""; font - Ariel,
PLAIN, size 12;
fontStyle - 0(regular text);
border - 23(sunken);
promptCharacter - '_';
insertEditMode - false;
editable - true;
alignment - 0(left justified);
odometer - 0(solid color);
shadow - 0(no shadow);
shadowWidth - 5;
text3D horizontal - 0;
text3D vertical - 0;
foreground - black;
backColor - white;
borderColor - gray;
highlightColor - dark blue;
shadowColor - gray;
text3DColor - green.
- See Also:
- setMask, setEditablePartOfText
PVMask
public PVMask()
- Constructor.
The mask is set to "********".
getEscapeChar
public char getEscapeChar()
- Get the character that disables mask flag-characters (#,
@, *).
- Returns:
- The character that disables mask flags.
- See Also:
- setEscapeChar
setEscapeChar
public void setEscapeChar(char escapeMaskChar)
- Set the character that disables mask flag-characters (#,
@, *). It allows to create the mask with these characters
as they are. It has effect only if it is in front of a
mask flag-character.
- Parameters:
- escapeMaskChar - the character that disables mask
flags.
Default value is set to '~'.
- See Also:
- setMask
getPromptChar
public char getPromptChar()
- Get the character that replaces not filled mask character
positions while editing text.
- Returns:
- The prompt character.
- See Also:
- setPromptChar
setPromptChar
public void setPromptChar(char promptCharacter)
- Set the character that replaces not filled mask character
positions while editing text.
- Parameters:
- promptCharacter - the prompt character while
editing a text.
Default value is set to the '_'.
- See Also:
- getPromptChar
setMask
public void setMask(String mask)
- Set mask string.
- Parameters:
- mask - string that defines mask with entry
validation.
Any character in the mask string, but special
mask character-flags (#, @, *), are the static
unchangable part of the resulting text string. On
the other hand, the mask flag-characters are
positions in the text string where new text can
be entered or modified.
Mask flag-characters can represent:
# - digit ('0'..'9'); @ - letter or space; * -
any printable character.
- See Also:
- setEscapeChar
getMask
public String getMask()
- Get mask string.
- Returns:
- String that represents mask.
- See Also:
- setMask
getText
public String getText()
- Get full text string.
- Returns:
- The text string how it appears in the PVMask when
it has no focus.
Not filled mask characters are replaced by the '
' characters.
- Overrides:
- getText
in class PVEdit
- See Also:
- getEditablePartOfText,
getMask, setText
getEditablePartOfText
public String getEditablePartOfText()
- Get a text string for the editable part of the PVMask.
- Returns:
- String that represents editable part of text.
- See Also:
- setEditablePartOfText,
getMask
setEditablePartOfText
public void setEditablePartOfText(String editableText)
- Set a text string for the editable part of the PVMask.
- Parameters:
- editableText - new editable part of text string.
If the new string is too long then it will be cut
off automatically. If the string is too short,
then the end of it will be filled up with spaces.
If the text contains characters that do not fit
in the mask, then they will be replaced by
spaces.
- See Also:
- getEditablePartOfText,
setMask
setText
public void setText(String text)
- Parameters:
- text - new text string. This method does not
change mask. Characters that located at the same
positions as static mask characters are ignored.
Characters that are at the editable mask
positions, but do not fit in mask will be
replaces by spaces. If the new string is too
long, then it will be cut off automatically. If
string is too short, then the end of it will be
filled up with spaces.
- Overrides:
- setText
in class PVEdit
- See Also:
- getEditablePartOfText