Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
public class JFormattedTextField
extends JTextField
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 |
|
static class |
|
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 |
|
static int | |
static int | |
static int |
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 | |
TOOL_TIP_TEXT_KEY , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW , accessibleContext , listenerList , ui |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver | |
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH |
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 |
Constructor Summary | |
| |
| |
| |
| |
| |
|
Method Summary | |
void |
|
Action[] |
|
int |
|
JFormattedTextField.AbstractFormatter |
|
JFormattedTextField.AbstractFormatterFactory |
|
String |
|
Object |
|
protected void |
|
boolean |
|
protected void |
|
void |
|
void |
|
protected void |
|
void |
|
void |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public JFormattedTextField()
Creates a JFormattedTextField with no formatter factory.setValue
orsetFormatterFactory
will properly configure this text field to edit a particular type of value.
public JFormattedTextField(Object value)
Creates a JFormattedTextField with the specified value. This creates a formatter and formatterFactory that are appropriate for the value.
- Parameters:
value
- the initial value for this JFormattedTextField
public JFormattedTextField(Format format)
Creates a JFormattedTextField that can handle the specified Format. An appopriate AbstractFormatter and AbstractFormatterFactory will be created for the specified Format.
- Parameters:
format
- the Format that this JFormattedTextField should be able to handle
public JFormattedTextField(JFormattedTextField.AbstractFormatter formatter)
Creates a JFormattedTextField with the specified formatter. This will create aDefaultFormatterFactory
with this formatter as the default formatter.
- Parameters:
formatter
- the formatter to use for this JFormattedTextField
public JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory)
Creates a JFormattedTextField with the specified formatter factory.
- Parameters:
factory
- the formatter factory to use for this JFormattedTextField
public JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory, Object value)
Creates a JFormattedTextField with the specified formatter factory and initial value.
- Parameters:
factory
- the initial formatter factory for this JFormattedTextFieldvalue
- the initial value for the text field
public void commitEdit() throws ParseException
Forces the current value from the editor to be set as the current value. If there is no current formatted this has no effect.
- Throws:
ParseException
- if the formatter cannot format the current value
public Action[] getActions()
Gets the command list supplied by the UI augmented by the specific Actions for JFormattedTextField.
- Overrides:
- getActions in interface JTextField
- Returns:
- an array of Actions that this text field supports
public int getFocusLostBehavior()
Returns the behaviour of this JFormattedTextField upon losing focus. This is one ofCOMMIT
,COMMIT_OR_REVERT
,PERSIST
, orREVERT
.
- Returns:
- the behaviour upon losing focus
public JFormattedTextField.AbstractFormatter getFormatter()
Returns the current formatter used for this JFormattedTextField.
- Returns:
- the current formatter used for this JFormattedTextField
public JFormattedTextField.AbstractFormatterFactory getFormatterFactory()
Returns the factory currently used to generate formatters for this JFormattedTextField.
- Returns:
- the factory currently used to generate formatters
public String getUIClassID()
Returns a string that specifies the name of the Look and Feel class that renders this component.
- Overrides:
- getUIClassID in interface JTextField
- Returns:
- the string "TextComponentUI"
public Object getValue()
Returns the last valid value. This may not be the value currently shown in the text field depending on whether or not the formatter commits on valid edits and allows invalid input to be temporarily displayed.
- Returns:
- the last committed valid value
protected void invalidEdit()
This method is used to provide feedback to the user when an invalid value is input during editing.
public boolean isEditValid()
Returns true if the current value being edited is valid. This property is managed by the current formatted.
- Returns:
- true if the value being edited is valid.
protected void processFocusEvent(FocusEvent evt)
Processes focus events. This is overridden because we may want to change the formatted depending on whether or not this field has focus.
- Overrides:
- processFocusEvent in interface Component
- Parameters:
evt
- the FocusEvent
public void setDocument(Document newDocument)
Associates this JFormattedTextField with a Document and propagates a PropertyChange event to each listener.
- Overrides:
- setDocument in interface JTextField
- Parameters:
newDocument
- the Document to associate with this text field
public void setFocusLostBehavior(int behavior)
Sets the behaviour of this JFormattedTextField upon losing focus. This must beCOMMIT
,COMMIT_OR_REVERT
,PERSIST
, orREVERT
or an IllegalArgumentException will be thrown.
- Parameters:
behavior
-
- Throws:
IllegalArgumentException
- ifbehaviour
is not one of the above
protected void setFormatter(JFormattedTextField.AbstractFormatter formatter)
Sets the formatter for this JFormattedTextField. Normally the formatter factory will take care of this, or calls to setValue will also make sure that the formatter is set appropriately.
- Parameters:
formatter
- the AbstractFormatter to use for formatting the value for this JFormattedTextField
public void setFormatterFactory(JFormattedTextField.AbstractFormatterFactory factory)
Sets the factory from which this JFormattedTextField should obtain its formatters.
- Parameters:
factory
- the AbstractFormatterFactory that will be used to generate formatters for this JFormattedTextField