|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
javax.swing.text
|
Constructor Summary | |
---|---|
InternationalFormatter()
Creates an InternationalFormatter with no
Format specified. |
|
InternationalFormatter(Format format)
Creates an InternationalFormatter with the specified
Format instance. |
Method Summary | |
---|---|
Object |
clone()
Creates a copy of the DefaultFormatter. |
protected Action[] |
getActions()
If getSupportsIncrement returns true, this returns
two Actions suitable for incrementing/decrementing the value. |
Format.Field[] |
getFields(int offset)
Returns the Format.Field constants associated with
the text at offset . |
Format |
getFormat()
Returns the format that dictates the legal values that can be edited and displayed. |
Comparable |
getMaximum()
Returns the maximum permissible value. |
Comparable |
getMinimum()
Returns the minimum permissible value. |
void |
install(JFormattedTextField ftf)
Installs the DefaultFormatter onto a particular
JFormattedTextField . |
void |
setFormat(Format format)
Sets the format that dictates the legal values that can be edited and displayed. |
void |
setMaximum(Comparable max)
Sets the maximum permissible value. |
void |
setMinimum(Comparable minimum)
Sets the minimum permissible value. |
Object |
stringToValue(String text)
Returns the Object representation of the
String text . |
String |
valueToString(Object value)
Returns a String representation of the Object value . |
Methods inherited from class javax.swing.text.DefaultFormatter |
---|
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode, setValueClass |
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter |
---|
getFormattedTextField, invalidEdit, setEditValid, uninstall |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public InternationalFormatter()
InternationalFormatter
with no
Format
specified.
public InternationalFormatter(Format format)
InternationalFormatter
with the specified
Format
instance.
format
- Format instance used for converting from/to StringsMethod Detail |
---|
public void setFormat(Format format)
format
- Format
instance used for converting
from/to Stringspublic Format getFormat()
public void setMinimum(Comparable minimum)
valueClass
has
not been specified, and minimum
is non null, the
valueClass
will be set to that of the class of
minimum
.
minimum
- Minimum legal value that can be inputDefaultFormatter.setValueClass(java.lang.Class>)
public Comparable getMinimum()
public void setMaximum(Comparable max)
valueClass
has
not been specified, and max
is non null, the
valueClass
will be set to that of the class of
max
.
max
- Maximum legal value that can be inputDefaultFormatter.setValueClass(java.lang.Class>)
public Comparable getMaximum()
public void install(JFormattedTextField ftf)
DefaultFormatter
onto a particular
JFormattedTextField
.
This will invoke valueToString
to convert the
current value from the JFormattedTextField
to
a String. This will then install the Action
s from
getActions
, the DocumentFilter
returned from getDocumentFilter
and the
NavigationFilter
returned from
getNavigationFilter
onto the
JFormattedTextField
.
Subclasses will typically only need to override this if they
wish to install additional listeners on the
JFormattedTextField
.
If there is a ParseException
in converting the
current value to a String, this will set the text to an empty
String, and mark the JFormattedTextField
as being
in an invalid state.
While this is a public method, this is typically only useful
for subclassers of JFormattedTextField
.
JFormattedTextField
will invoke this method at
the appropriate times when the value changes, or its internal
state changes.
install
in class DefaultFormatter
ftf
- JFormattedTextField to format for, may be null indicating
uninstall from current JFormattedTextField.public String valueToString(Object value) throws ParseException
value
.
This invokes format
on the current Format
.
valueToString
in class DefaultFormatter
value
- Value to convert
ParseException
- if there is an error in the conversionpublic Object stringToValue(String text) throws ParseException
Object
representation of the
String
text
.
stringToValue
in class DefaultFormatter
text
- String
to convert
Object
representation of text
ParseException
- if there is an error in the conversionpublic Format.Field[] getFields(int offset)
Format.Field
constants associated with
the text at offset
. If offset
is not
a valid location into the current text, this will return an
empty array.
offset
- offset into text to be examined
public Object clone() throws CloneNotSupportedException
clone
in class DefaultFormatter
CloneNotSupportedException
- if the object's class does not
support the Cloneable
interface. Subclasses
that override the clone
method can also
throw this exception to indicate that an instance cannot
be cloned.Cloneable
protected Action[] getActions()
getSupportsIncrement
returns true, this returns
two Actions suitable for incrementing/decrementing the value.
getActions
in class JFormattedTextField.AbstractFormatter