|
Préférences
Moteurs de recherche
|
||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.6.0
javax.swing
|
Constructor Summary | |
---|---|
JFormattedTextField.AbstractFormatter()
|
Method Summary | |
---|---|
protected Object |
clone()
Clones the AbstractFormatter . |
protected Action[] |
getActions()
Subclass and override if you wish to provide a custom set of Action s. |
protected DocumentFilter |
getDocumentFilter()
Subclass and override if you wish to provide a DocumentFilter to restrict what can be input. |
protected JFormattedTextField |
getFormattedTextField()
Returns the current JFormattedTextField the
AbstractFormatter is installed on. |
protected NavigationFilter |
getNavigationFilter()
Subclass and override if you wish to provide a filter to restrict where the user can navigate to. |
void |
install(JFormattedTextField ftf)
Installs the AbstractFormatter onto a particular
JFormattedTextField . |
protected void |
invalidEdit()
This should be invoked when the user types an invalid character. |
protected void |
setEditValid(boolean valid)
Invoke this to update the editValid property of the
JFormattedTextField . |
abstract Object |
stringToValue(String text)
Parses text returning an arbitrary Object. |
void |
uninstall()
Uninstalls any state the AbstractFormatter may have
installed on the JFormattedTextField . |
abstract String |
valueToString(Object value)
Returns the string value to display for value . |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JFormattedTextField.AbstractFormatter()
Method Detail |
---|
public void install(JFormattedTextField ftf)
AbstractFormatter
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. You will only need to invoke this yourself if
you are subclassing JFormattedTextField
and
installing/uninstalling AbstractFormatter
at a
different time than JFormattedTextField
does.
ftf
- JFormattedTextField to format for, may be null indicating
uninstall from current JFormattedTextField.public void uninstall()
AbstractFormatter
may have
installed on the JFormattedTextField
. This resets the
DocumentFilter
, NavigationFilter
and additional Action
s installed on the
JFormattedTextField
.
public abstract Object stringToValue(String text) throws ParseException
text
returning an arbitrary Object. Some
formatters may return null.
text
- String to convert
ParseException
- if there is an error in the conversionpublic abstract String valueToString(Object value) throws ParseException
value
.
value
- Value to convert
ParseException
- if there is an error in the conversionprotected JFormattedTextField getFormattedTextField()
JFormattedTextField
the
AbstractFormatter
is installed on.
protected void invalidEdit()
protected void setEditValid(boolean valid)
editValid
property of the
JFormattedTextField
. If you an enforce a policy
such that the JFormattedTextField
is always in a
valid state, you will never need to invoke this.
valid
- Valid state of the JFormattedTextFieldprotected Action[] getActions()
Action
s. install
will install these
on the JFormattedTextField
's ActionMap
.
protected DocumentFilter getDocumentFilter()
DocumentFilter
to restrict what can be input.
install
will install the returned value onto
the JFormattedTextField
.
protected NavigationFilter getNavigationFilter()
install
will install the returned value onto
the JFormattedTextField
.
protected Object clone() throws CloneNotSupportedException
AbstractFormatter
. The returned instance
is not associated with a JFormattedTextField
.
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