|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.JFormattedTextField.AbstractFormatter
javax.swing.text.DefaultFormatter
public class DefaultFormatter
The DefaultFormatter
is a concrete formatter for use in
JFormattedTextField
s.
It can format arbitrary values by invoking
their Object.toString()
method.
In order to convert a String back to
a value, the value class must provide a single argument constructor that
takes a String object as argument value. If no such constructor is found,
the String itself is passed back by #stringToValue.
Constructor Summary | |
---|---|
DefaultFormatter()
Creates a new instance of DefaultFormatter . |
Method Summary | |
---|---|
Object |
clone()
Creates and returns a clone of this DefaultFormatter. |
boolean |
getAllowsInvalid()
Returns whether or not invalid edits are allowed or not. |
boolean |
getCommitsOnValidEdit()
Returns true if the value should be committed after
each valid modification of the input field, false if
it should never be committed by this formatter. |
protected DocumentFilter |
getDocumentFilter()
Returns the DocumentFilter that is used to restrict input. |
boolean |
getOverwriteMode()
Returns the value of the overwriteMode property. |
Class<?> |
getValueClass()
Returns the class that is used for values. |
void |
install(JFormattedTextField ftf)
Installs the formatter on the specified JFormattedTextField . |
void |
setAllowsInvalid(boolean allowsInvalid)
Sets the value of the allowsInvalid property. |
void |
setCommitsOnValidEdit(boolean commitsOnValidEdit)
Sets the value of the commitsOnValidEdit property. |
void |
setOverwriteMode(boolean overwriteMode)
Sets the value of the overwriteMode property. |
void |
setValueClass(Class<?> valueClass)
Sets the class that is used for values. |
Object |
stringToValue(String string)
Converts a String (from the JFormattedTextField input) to a value. |
String |
valueToString(Object value)
Converts a value object into a String. |
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter |
---|
getActions, getFormattedTextField, getNavigationFilter, invalidEdit, setEditValid, uninstall |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultFormatter()
DefaultFormatter
.
Method Detail |
---|
public void install(JFormattedTextField ftf)
JFormattedTextField
.
This method does the following things:
JFormattedTextField
JTextField
install
in class JFormattedTextField.AbstractFormatter
ftf
- the JFormattedTextField
in which this formatter
is installedpublic boolean getCommitsOnValidEdit()
true
if the value should be committed after
each valid modification of the input field, false
if
it should never be committed by this formatter.
commitsOnValidEdit
propertysetCommitsOnValidEdit(boolean)
public void setCommitsOnValidEdit(boolean commitsOnValidEdit)
commitsOnValidEdit
property.
commitsOnValidEdit
- the new state of the
commitsOnValidEdit
propertygetCommitsOnValidEdit()
public boolean getOverwriteMode()
overwriteMode
property.
If that is set to true
then newly inserted characters
overwrite existing values, otherwise the characters are inserted like
normal. The default is true
.
overwriteMode
propertypublic void setOverwriteMode(boolean overwriteMode)
overwriteMode
property.
If that is set to true
then newly inserted characters
overwrite existing values, otherwise the characters are inserted like
normal. The default is true
.
overwriteMode
- the new value for the overwriteMode
propertypublic boolean getAllowsInvalid()
public void setAllowsInvalid(boolean allowsInvalid)
allowsInvalid
property.
allowsInvalid
- the new value for the propertygetAllowsInvalid()
public Class<?> getValueClass()
public void setValueClass(Class<?> valueClass)
valueClass
- the class that is used for valuesgetValueClass()
public Object stringToValue(String string) throws ParseException
stringToValue
in class JFormattedTextField.AbstractFormatter
string
- the string to convert
ParseException
- if the string cannot be converted into
a value object (e.g. invalid input)public String valueToString(Object value) throws ParseException
Object.toString()
method on the value.
valueToString
in class JFormattedTextField.AbstractFormatter
value
- the value to be converted
ParseException
- if the value cannot be convertedpublic Object clone() throws CloneNotSupportedException
clone
in class JFormattedTextField.AbstractFormatter
CloneNotSupportedException
- not thrown hereCloneable
protected DocumentFilter getDocumentFilter()
getDocumentFilter
in class JFormattedTextField.AbstractFormatter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |