javax.swing.text
public class MaskFormatter extends DefaultFormatter
Constructor Summary | |
---|---|
MaskFormatter() | |
MaskFormatter(String mask)
Creates a MaskFormatter with the specified mask. |
Method Summary | |
---|---|
String | getInvalidCharacters()
Returns a String containing the characters that are not valid for input
for this MaskFormatter. |
String | getMask()
Returns the mask used in this MaskFormatter. |
String | getPlaceholder()
Returns the place holder String that is used in place of missing
characters when the value doesn't completely fill in the spaces
in the mask. |
char | getPlaceholderCharacter()
Returns the character used in place of missing characters when the
value doesn't completely fill the mask. |
String | getValidCharacters()
Returns a String containing the characters that are valid for input
for this MaskFormatter. |
boolean | getValueContainsLiteralCharacters()
Returns true if stringToValue should return the literal
characters in the mask. |
void | install(JFormattedTextField ftf)
Installs this MaskFormatter on the JFormattedTextField.
|
void | setInvalidCharacters(String invalidCharacters)
Sets characters that are not valid for input. |
void | setMask(String mask)
Sets the mask for this MaskFormatter. |
void | setPlaceholder(String placeholder)
Sets the string to use if the value does not completely fill in the mask.
|
void | setPlaceholderCharacter(char placeholder)
Sets the char to use if the value does not completely fill in the mask.
|
void | setValidCharacters(String validCharacters)
Sets characters that are valid for input. |
void | setValueContainsLiteralCharacters(boolean containsLiteralChars)
Determines whether stringToValue will return literal characters or not. |
Object | stringToValue(String value)
Parses the text using the mask, valid characters, and invalid characters
to determine the appropriate Object to return. |
String | valueToString(Object value)
Returns a String representation of the Object value based on the mask.
|
Parameters: mask
Throws: java.text.ParseException
UNKNOWN: doesn't actually throw a ParseException although it is declared to do so
Returns: a String containing the invalid characters.
Returns: the mask used in this MaskFormatter.
Returns: the place holder String.
Returns: the place holder character
Returns: a String containing the valid characters.
Returns: true if stringToValue should return the literal characters in the mask
invalidCharacters
is non-null then no characters contained
in it will be allowed to be input.
Parameters: invalidCharacters the String specifying invalid characters.
Parameters: mask the new mask for this MaskFormatter
Throws: ParseException if mask
is not valid.
UNKNOWN: doesn't actually throw a ParseException even though it is declared to do so
Parameters: placeholder the String to use if the value doesn't completely fill in the mask.
Parameters: placeholder the char to use if the value doesn't completely fill in the mask.
validCharacters
is non-null then no characters that are
not contained in it will be allowed to be input.
Parameters: validCharacters the String specifying valid characters.
Parameters: containsLiteralChars if true, stringToValue will return the literal characters in the mask, otherwise it will not.
Parameters: value the String to parse
Throws: ParseException if value doesn't match the mask and valid/invalid character sets
Parameters: value the value to convert
Throws: ParseException if value is invalid for this mask and valid/invalid character sets