|
|||||||||
| 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
javax.swing.text.InternationalFormatter
public class InternationalFormatter
This extends DefaultFormatter so that the value to string
conversion is done via a Format object. This allows
various additional formats to be handled by JFormattedField.
| Constructor Summary | |
|---|---|
InternationalFormatter()
Creates a new InternationalFormatter with no Format specified. |
|
InternationalFormatter(Format format)
Creates a new InternationalFormatter that uses the specified Format object for value to string conversion. |
|
| Method Summary | |
|---|---|
Object |
clone()
This creates and returns a clone of this Formatter. |
protected Action[] |
getActions()
Returns the Actions that are supported by this Formatter. |
Format.Field[] |
getFields(int offset)
Returns the Format.Field constants that are associated with
the specified position in the text. |
Format |
getFormat()
Returns the currently used Format object that is used to format the JFormattedField. |
Comparable |
getMaximum()
Returns the maximal value that is allowed by this Formatter. |
Comparable |
getMinimum()
Returns the minimal value that is allowed by this Formatter. |
void |
install(JFormattedTextField ftf)
Installs the formatter on the specified JFormattedTextField. |
void |
setFormat(Format format)
Sets the Format object that is used to convert values to strings. |
void |
setMaximum(Comparable maxValue)
Sets the maximum value that is allowed by this Formatter. |
void |
setMinimum(Comparable minValue)
Sets the minimum value that is allowed by this Formatter. |
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.text.DefaultFormatter |
|---|
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass |
| Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter |
|---|
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 InternationalFormatter()
public InternationalFormatter(Format format)
format - the Format object to use for value to string conversion| Method Detail |
|---|
public void setFormat(Format format)
format - the Format to use for value to string conversionFormatpublic Format getFormat()
public void setMinimum(Comparable minValue)
Comparable
interface.
If minValue is null, then the Formatter has no restrictions
at the lower end.
If value class is not yet specified and minValue is not
null, then valueClass is set to the class of the minimum
value.
minValue - the minimum permissable valueComparablepublic Comparable getMinimum()
null value means that there is no restriction.
null if there is no restrictionpublic void setMaximum(Comparable maxValue)
Comparable
interface.
If maxValue is null, then the Formatter has no restrictions
at the upper end.
If value class is not yet specified and maxValue is not
null, then valueClass is set to the class of the maximum
value.
maxValue - the maximum permissable valueComparablepublic Comparable getMaximum()
null value means that there is no restriction.
null if there is no restrictionpublic void install(JFormattedTextField ftf)
JFormattedTextField.
This method does the following things:
JFormattedTextFieldJTextField
install in class DefaultFormatterftf - the JFormattedTextField in which this formatter
is installed
public String valueToString(Object value)
throws ParseException
Format.format(Object) on the specified Format object.
If no format is set, then DefaultFormatter.valueToString(Object)
is called as a fallback.
valueToString in class DefaultFormattervalue - the value to be converted
ParseException - if the value cannot be converted
public Object stringToValue(String string)
throws ParseException
Format.parseObject(String) on
the specified Format object.
This implementation differs slightly from DefaultFormatter,
it does:
Object using the
Formatter.valueClass has been set, this object is passed to
DefaultFormatter.stringToValue(String) so that the value
has the correct type. This may or may not work correctly, depending on
the implementation of toString() in the value class and if the class
implements a constructor that takes one String as argument.ParseException has been thrown so far, we check if the
value exceeds either minimum or maximum if
one of those has been specified and throw a ParseException
if it does.DefaultFormatter.stringToValue(String) is invoked as fallback.
stringToValue in class DefaultFormatterstring - the string to convert
ParseException - if the string cannot be converted into
a value object (e.g. invalid input)public Format.Field[] getFields(int offset)
Format.Field constants that are associated with
the specified position in the text.
If offset is not a valid location in the input field,
an empty array of fields is returned.
offset - the position in the text from which we want to fetch
the fields constants
public Object clone()
throws CloneNotSupportedException
clone in class DefaultFormatterCloneNotSupportedException - not thrown here, since cloning is
supportedCloneableprotected Action[] getActions()
getActions in class JFormattedTextField.AbstractFormatternull. Should be subclassed by formatters that want
to install custom Actions on the JFormattedTextField.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||