|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
javax.swing.JFormattedTextField
public class JFormattedTextField
A text field that makes use of a formatter to display and edit a specific
type of data. The value that is displayed can be an arbitrary object. The
formatter is responsible for displaying the value in a textual form and
it may allow editing of the value.
Formatters are usually obtained using an instance of
JFormattedTextField.AbstractFormatterFactory
. This factory is responsible for providing
an instance of JFormattedTextField.AbstractFormatter
that is able to handle the
formatting of the value of the JFormattedTextField.
Nested Class Summary | |
---|---|
static class |
JFormattedTextField.AbstractFormatter
An abstract base implementation for a formatter that can be used by a JTextField. |
static class |
JFormattedTextField.AbstractFormatterFactory
Delivers instances of an JFormattedTextField.AbstractFormatter for
a specific value type for a JFormattedTextField. |
Nested classes/interfaces inherited from class javax.swing.JTextField |
---|
JTextField.AccessibleJTextField |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
---|
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
COMMIT
The possible focusLostBehavior options |
static int |
COMMIT_OR_REVERT
|
static int |
PERSIST
|
static int |
REVERT
|
Fields inherited from class javax.swing.JTextField |
---|
notifyAction |
Fields inherited from class javax.swing.text.JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
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()
Returns the class ID for the UI. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int COMMIT
public static final int COMMIT_OR_REVERT
public static final int REVERT
public static final int PERSIST
Constructor Detail |
---|
public JFormattedTextField()
setValue
or setFormatterFactory
will
properly configure this text field to edit a particular type
of value.
public JFormattedTextField(Format format)
format
- the Format that this JFormattedTextField should be able
to handlepublic JFormattedTextField(JFormattedTextField.AbstractFormatter formatter)
DefaultFormatterFactory
with this formatter as the default
formatter.
formatter
- the formatter to use for this JFormattedTextFieldpublic JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory)
factory
- the formatter factory to use for this JFormattedTextFieldpublic JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory, Object value)
factory
- the initial formatter factory for this JFormattedTextFieldvalue
- the initial value for the text fieldpublic JFormattedTextField(Object value)
value
- the initial value for this JFormattedTextFieldMethod Detail |
---|
public void commitEdit() throws ParseException
ParseException
- if the formatter cannot format the current valuepublic Action[] getActions()
getActions
in class JTextField
TextUI.getEditorKit(javax.swing.text.JTextComponent)
,
EditorKit.getActions()
public int getFocusLostBehavior()
COMMIT
, COMMIT_OR_REVERT
,
PERSIST
, or REVERT
.
public JFormattedTextField.AbstractFormatter getFormatter()
public JFormattedTextField.AbstractFormatterFactory getFormatterFactory()
public String getUIClassID()
JTextField
getUIClassID
in class JTextField
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public Object getValue()
protected void invalidEdit()
public boolean isEditValid()
protected void processFocusEvent(FocusEvent evt)
processFocusEvent
in class Component
evt
- the FocusEventFocusListener
,
Component.addFocusListener(FocusListener)
,
Component.enableEvents(long)
public void setDocument(Document newDocument)
setDocument
in class JTextField
newDocument
- the Document to associate with this text fieldpublic void setFocusLostBehavior(int behavior)
COMMIT
, COMMIT_OR_REVERT
,
PERSIST
, or REVERT
or an
IllegalArgumentException will be thrown.
behavior
-
IllegalArgumentException
- if behaviour
is not
one of the aboveprotected void setFormatter(JFormattedTextField.AbstractFormatter formatter)
formatter
- the AbstractFormatter to use for formatting the value for
this JFormattedTextFieldpublic void setFormatterFactory(JFormattedTextField.AbstractFormatterFactory factory)
factory
- the AbstractFormatterFactory that will be used to generate
formatters for this JFormattedTextFieldpublic void setValue(Object newValue)
newValue
- the value to be formatted and displayed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |