javax.swing
public class JFormattedTextField extends JTextField
Since: 1.4
| Nested Class Summary | |
|---|---|
| abstract static class | JFormattedTextField.AbstractFormatter
An abstract base implementation for a formatter that can be used by
a JTextField. |
| abstract static class | JFormattedTextField.AbstractFormatterFactory
Delivers instances of an {@link AbstractFormatter} for
a specific value type for a JFormattedTextField. |
| Field Summary | |
|---|---|
| static int | COMMIT The possible focusLostBehavior options * |
| static int | COMMIT_OR_REVERT |
| static int | PERSIST |
| static int | REVERT |
| Constructor Summary | |
|---|---|
| JFormattedTextField()
Creates a JFormattedTextField with no formatter factory.
| |
| JFormattedTextField(Format format)
Creates a JFormattedTextField that can handle the specified Format.
| |
| JFormattedTextField(JFormattedTextField.AbstractFormatter formatter)
Creates a JFormattedTextField with the specified formatter. | |
| JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory)
Creates a JFormattedTextField with the specified formatter factory.
| |
| JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory, Object value)
Creates a JFormattedTextField with the specified formatter factory and
initial value.
| |
| JFormattedTextField(Object value)
Creates a JFormattedTextField with the specified value. | |
| Method Summary | |
|---|---|
| void | commitEdit()
Forces the current value from the editor to be set as the current
value. |
| Action[] | getActions()
Gets the command list supplied by the UI augmented by the specific
Actions for JFormattedTextField.
|
| int | getFocusLostBehavior()
Returns the behaviour of this JFormattedTextField upon losing focus. |
| JFormattedTextField.AbstractFormatter | getFormatter()
Returns the current formatter used for this JFormattedTextField. |
| JFormattedTextField.AbstractFormatterFactory | getFormatterFactory()
Returns the factory currently used to generate formatters for this
JFormattedTextField. |
| String | getUIClassID() |
| Object | getValue()
Returns the last valid value. |
| protected void | invalidEdit()
This method is used to provide feedback to the user when an invalid value
is input during editing. |
| boolean | isEditValid()
Returns true if the current value being edited is valid. |
| protected void | processFocusEvent(FocusEvent evt)
Processes focus events. |
| void | setDocument(Document newDocument)
Associates this JFormattedTextField with a Document and propagates
a PropertyChange event to each listener.
|
| void | setFocusLostBehavior(int behavior)
Sets the behaviour of this JFormattedTextField upon losing focus.
|
| protected void | setFormatter(JFormattedTextField.AbstractFormatter formatter)
Sets the formatter for this JFormattedTextField. |
| void | setFormatterFactory(JFormattedTextField.AbstractFormatterFactory factory)
Sets the factory from which this JFormattedTextField should obtain
its formatters.
|
| void | setValue(Object newValue)
Sets the value that will be formatted and displayed.
|
setValue or setFormatterFactory will
properly configure this text field to edit a particular type
of value.Parameters: format the Format that this JFormattedTextField should be able to handle
Parameters: formatter the formatter to use for this JFormattedTextField
Parameters: factory the formatter factory to use for this JFormattedTextField
Parameters: factory the initial formatter factory for this JFormattedTextField value the initial value for the text field
Parameters: value the initial value for this JFormattedTextField
Throws: ParseException if the formatter cannot format the current value
Returns: an array of Actions that this text field supports
COMMIT, COMMIT_OR_REVERT,
PERSIST, or REVERT.Returns: the behaviour upon losing focus
Returns: the current formatter used for this JFormattedTextField
Returns: the factory currently used to generate formatters
Returns: the last committed valid value
Returns: true if the value being edited is valid.
Parameters: evt the FocusEvent
Parameters: newDocument the Document to associate with this text field
COMMIT, COMMIT_OR_REVERT,
PERSIST, or REVERT or an
IllegalArgumentException will be thrown.
Parameters: behavior
Throws: IllegalArgumentException if behaviour is not
one of the above
Parameters: formatter the AbstractFormatter to use for formatting the value for this JFormattedTextField
Parameters: factory the AbstractFormatterFactory that will be used to generate formatters for this JFormattedTextField
Parameters: newValue the value to be formatted and displayed