public class MaskFormatter extends DefaultFormatter
| Constructor and Description |
|---|
MaskFormatter() |
MaskFormatter(java.lang.String mask)
Creates a MaskFormatter with the specified mask.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getInvalidCharacters()
Returns a String containing the characters that are not valid for input
for this MaskFormatter.
|
java.lang.String |
getMask()
Returns the mask used in this MaskFormatter.
|
java.lang.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.
|
java.lang.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(javax.swing.JFormattedTextField ftf)
Installs this MaskFormatter on the JFormattedTextField.
|
void |
setInvalidCharacters(java.lang.String invalidCharacters)
Sets characters that are not valid for input.
|
void |
setMask(java.lang.String mask)
Sets the mask for this MaskFormatter.
|
void |
setPlaceholder(java.lang.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(java.lang.String validCharacters)
Sets characters that are valid for input.
|
void |
setValueContainsLiteralCharacters(boolean containsLiteralChars)
Determines whether stringToValue will return literal characters or not.
|
java.lang.Object |
stringToValue(java.lang.String value)
Parses the text using the mask, valid characters, and invalid characters
to determine the appropriate Object to return.
|
java.lang.String |
valueToString(java.lang.Object value)
Returns a String representation of the Object value based on the mask.
|
clone, getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClasspublic MaskFormatter()
public MaskFormatter(java.lang.String mask) throws java.text.ParseException
mask - java.text.ParseExceptionpublic java.lang.String getMask()
public java.lang.String getInvalidCharacters()
public void setInvalidCharacters(java.lang.String invalidCharacters)
invalidCharacters is non-null then no characters contained
in it will be allowed to be input.invalidCharacters - the String specifying invalid characters.public java.lang.String getValidCharacters()
public void setValidCharacters(java.lang.String validCharacters)
validCharacters is non-null then no characters that are
not contained in it will be allowed to be input.validCharacters - the String specifying valid characters.public java.lang.String getPlaceholder()
public void setPlaceholder(java.lang.String placeholder)
placeholder - the String to use if the value doesn't completely
fill in the mask.public char getPlaceholderCharacter()
public void setPlaceholderCharacter(char placeholder)
placeholder - the char to use if the value doesn't completely
fill in the mask.public boolean getValueContainsLiteralCharacters()
public void setValueContainsLiteralCharacters(boolean containsLiteralChars)
containsLiteralChars - if true, stringToValue will return the
literal characters in the mask, otherwise it will not.public void setMask(java.lang.String mask) throws java.text.ParseException
mask - the new mask for this MaskFormatterjava.text.ParseException - if mask is not valid.public void install(javax.swing.JFormattedTextField ftf)
install in class DefaultFormatterftf - the JFormattedTextField in which this formatter
is installedpublic java.lang.Object stringToValue(java.lang.String value) throws java.text.ParseException
stringToValue in class DefaultFormattervalue - the String to parsejava.text.ParseException - if value doesn't match the mask and valid/invalid
character setspublic java.lang.String valueToString(java.lang.Object value) throws java.text.ParseException
valueToString in class DefaultFormattervalue - the value to convertjava.text.ParseException - if value is invalid for this mask and valid/invalid
character sets