| public abstract static class javax.swing JFormattedTextField.AbstractFormatter
|
Java SE 6 |
AbstractFormatter are used by
JFormattedTextField to handle the conversion both
from an Object to a String, and back from a String to an Object.
AbstractFormatters can also enfore editing policies,
or navigation policies, or manipulate the
JFormattedTextField in any way it sees fit to
enforce the desired policy.
An AbstractFormatter can only be active in
one JFormattedTextField at a time.
JFormattedTextField invokes
install when it is ready to use it followed
by uninstall when done. Subclasses
that wish to install additional state should override
install and message super appropriately.
Subclasses must override the conversion methods
stringToValue and valueToString. Optionally
they can override getActions,
getNavigationFilter and getDocumentFilter
to restrict the JFormattedTextField in a particular
way.
Subclasses that allow the JFormattedTextField to be in
a temporarily invalid state should invoke setEditValid
at the appropriate times.
| since | 1.4 |
| Constructors | |
|---|---|
| public | JFormattedTextField.AbstractFormatter() |
| Methods | |||||||
|---|---|---|---|---|---|---|---|
| protected Object | clone() throws CloneNotSupportedException Details
Clones the AbstractFormatter. The returned instance
is not associated with a JFormattedTextField.
| ||||||
| public void | install(JFormattedTextField ftf) Details
Installs the 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 Actions 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
If there is a
While this is a public method, this is typically only useful
for subclassers of
| ||||||
| protected void | invalidEdit() This should be invoked when the user types an invalid character. This forwards the call to the current JFormattedTextField. | ||||||
| abstract public Object | stringToValue(String text) throws ParseException Details
Parses text returning an arbitrary Object. Some
formatters may return null.
| ||||||
| public void | uninstall() Uninstalls any state the AbstractFormatter may have
installed on the JFormattedTextField. This resets the
DocumentFilter, NavigationFilter
and additional Actions installed on the
JFormattedTextField.
| ||||||
| abstract public String | valueToString(Object value) throws ParseException Details
Returns the string value to display for value.
| ||||||
| Properties | |||
|---|---|---|---|
| protected Action[] | getActions() Details
Subclass and override if you wish to provide a custom set of
Actions. install will install these
on the JFormattedTextField's ActionMap.
| ||
| protected DocumentFilter | getDocumentFilter() Details
Subclass and override if you wish to provide a
DocumentFilter to restrict what can be input.
install will install the returned value onto
the JFormattedTextField.
| ||
| protected void | setEditValid(boolean valid) Details
Invoke this to update the 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.
| ||
| protected JFormattedTextField | getFormattedTextField() Details
Returns the current JFormattedTextField the
AbstractFormatter is installed on.
| ||
| protected NavigationFilter | getNavigationFilter() Details
Subclass and override if you wish to provide a filter to restrict
where the user can navigate to.
install will install the returned value onto
the JFormattedTextField.
| ||
| About DocWeb · Bundles · Export · Export All | Top 10 · Statistics · Login |
| About Sun · Contact · Privacy · Terms of Use · Trademarks | Java SE 6 · Copyright © 1994-2013 Sun Microsystems, Inc.All rights reserved. Use is subject to license terms |
![]() |
![]() |
|