java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.text.JTextComponent | +--javax.swing.JTextField | +--javax.swing.JFormattedTextField
Safe:
static int
COMMIT
commitEdit should be invoked.
static int
COMMIT_OR_REVERT
commitEdit should be invoked.
private javax.swing.JFormattedTextField.AbstractFormatterFactory
factory
private javax.swing.JFormattedTextField.AbstractFormatter
format
static int
PERSIST
static int
REVERT
JFormattedTextField.
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatter formatter)
JFormattedTextField with the specified
AbstractFormatter.
JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory factory)
JFormattedTextField with the specified
AbstractFormatterFactory.
JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory factory,
Object currentValue)
JFormattedTextField with the specified
AbstractFormatterFactory and initial value.
JFormattedTextField(Object value)
void
commitEdit()
AbstractFormatter and set as the current value.
private javax.swing.JFormattedTextField.AbstractFormatterFactory
getDefaultFormatterFactory(Object type)
javax.swing.JFormattedTextField.AbstractFormatter
getFormatter()
AbstractFormatter that is used to format and
parse the current value.
javax.swing.JFormattedTextField.AbstractFormatterFactory
getFormatterFactory()
AbstractFormatterFactory.
protected void
processFocusEvent(FocusEvent e)
FocusEvent.FOCUS_GAINED or
FocusEvent.FOCUS_LOST.
protected void
setFormatter(javax.swing.JFormattedTextField.AbstractFormatter format)
AbstractFormatter.
private void
setFormatterActions(Action[] actions)
actions.
void
setFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory tf)
AbstractFormatterFactory.
void
setValue(Object value)
AbstractFormatter obtained from the current
AbstractFormatterFactory.
private void
setValue(Object value,
boolean createFormat)
private void
writeObject(ObjectOutputStream s)
readObject and writeObject in
JComponent for more
information about serialization in Swing.
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, hasActionListener, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setFont, setHorizontalAlignment, setScrollOffset
addCaretListener, addInputMethodListener, addKeymap, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, get, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, size, transferFocusBackward, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, toString, transferFocus, transferFocus, transferFocusUpCycle
private static final String uiClassID
private static final Action[] defaultActions
public static final int COMMIT
commitEdit should be invoked. If in commiting the
new value a ParseException is thrown, the invalid
value will remain.
setFocusLostBehavior(int)public static final int COMMIT_OR_REVERT
commitEdit should be invoked. If in commiting the new
value a ParseException is thrown, the value will be
reverted.
setFocusLostBehavior(int)public static final int REVERT
JFormattedTextField.
setFocusLostBehavior(int)public static final int PERSIST
setFocusLostBehavior(int)private javax.swing.JFormattedTextField.AbstractFormatterFactory factory
private javax.swing.JFormattedTextField.AbstractFormatter format
private Object value
private boolean editValid
private int focusLostBehavior
private boolean edited
private DocumentListener documentListener
private Object mask
private ActionMap textFormatterActionMap
public JFormattedTextField()
JFormattedTextField with no
AbstractFormatterFactory. Use setMask or
setFormatterFactory to configure the
JFormattedTextField to edit a particular type of
value.
public JFormattedTextField(Object value)
AbstractFormatterFactory based on the
type of value.
value - Initial value for the JFormattedTextFieldpublic JFormattedTextField(java.text.Format format)
JFormattedTextField. format is
wrapped in an appropriate AbstractFormatter which is
then wrapped in an AbstractFormatterFactory.
format - Format used to look up an AbstractFormatterpublic JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatter formatter)
JFormattedTextField with the specified
AbstractFormatter. The AbstractFormatter
is placed in an AbstractFormatterFactory.
formatter - AbstractFormatter to use for formatting.public JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory factory)
JFormattedTextField with the specified
AbstractFormatterFactory.
factory - AbstractFormatterFactory used for formatting.public JFormattedTextField(javax.swing.JFormattedTextField.AbstractFormatterFactory factory, Object currentValue)
JFormattedTextField with the specified
AbstractFormatterFactory and initial value.
factory - AbstractFormatterFactory used for
formatting.currentValue - Initial value to usepublic void setFocusLostBehavior(int behavior)
JFormattedTextField.COMMIT_OR_REVERT,
JFormattedTextField.REVERT,
JFormattedTextField.COMMIT or
JFormattedTextField.PERSIST
Note that some AbstractFormatters may push changes as
they occur, so that the value of this will have no effect.
This will throw an IllegalArgumentException if the object
passed in is not one of the afore mentioned values.
The default value of this property is
JFormattedTextField.COMMIT_OR_REVERT.
behavior - Identifies behavior when focus is lost
IllegalArgumentException - if behavior is not one of the known
valuespublic int getFocusLostBehavior()
COMMIT_OR_REVERT,
COMMIT,
REVERT or
PERSIST
Note that some AbstractFormatters may push changes as
they occur, so that the value of this will have no effect.
public void setFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory tf)
AbstractFormatterFactory.
AbstractFormatterFactory is
able to return an instance of AbstractFormatter that is
used to format a value for display, as well an enforcing an editing
policy.
If you have not explicitly set an AbstractFormatterFactory
by way of this method (or a constructor) an
AbstractFormatterFactory and consequently an
AbstractFormatter will be used based on the
Class of the value. NumberFormatter will
be used for Numbers, DateFormatter will
be used for Dates, otherwise DefaultFormatter
will be used.
This is a JavaBeans bound property.
tf - AbstractFormatterFactory used to lookup
instances of AbstractFormatterpublic javax.swing.JFormattedTextField.AbstractFormatterFactory getFormatterFactory()
AbstractFormatterFactory.
AbstractFormatterFactory used to determine
AbstractFormatterssetFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory)protected void setFormatter(javax.swing.JFormattedTextField.AbstractFormatter format)
AbstractFormatter.
You should not normally invoke this, instead set the
AbstractFormatterFactory or set the value.
JFormattedTextField will
invoke this as the state of the JFormattedTextField
changes and requires the value to be reset.
JFormattedTextField passes in the
AbstractFormatter obtained from the
AbstractFormatterFactory.
This is a JavaBeans bound property.
format - AbstractFormatter to use for formattingsetFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory)public javax.swing.JFormattedTextField.AbstractFormatter getFormatter()
AbstractFormatter that is used to format and
parse the current value.
public void setValue(Object value)
AbstractFormatter obtained from the current
AbstractFormatterFactory. If no
AbstractFormatterFactory has been specified, this will
attempt to create one based on the type of value.
The default value of this property is null.
This is a JavaBeans bound property.
public Object getValue()
AbstractFormatter this may not return the current
value. The currently edited value can be obtained by invoking
commitEdit followed by getValue.
public void commitEdit() throws java.text.ParseException
AbstractFormatter and set as the current value.
This has no effect if there is no current
AbstractFormatter installed.
ParseException - if the AbstractFormatter is not able
to format the current valueprivate void setEditValid(boolean isValid)
AbstractFormatter as the user edits the value.
Not all formatters will allow the component to get into an invalid state, and thus this may never be invoked.
Based on the look and feel this may visually change the state of the receiver.
isValid - boolean indicating if the currently edited value is
valid.public boolean isEditValid()
AbstractFormatter, as such
there is no public setter for it.
protected void invalidEdit()
protected void processFocusEvent(FocusEvent e)
FocusEvent.FOCUS_GAINED or
FocusEvent.FOCUS_LOST.
processFocusEvent in class Componente - the FocusEventFocusEventpublic Action[] getActions()
getActions in class JTextFieldpublic String getUIClassID()
getUIClassID in class JTextFieldJComponent.getUIClassID()public void setDocument(Document doc)
setDocument in class JTextFielddoc - the document to display/editJTextComponent.getDocument()private void writeObject(ObjectOutputStream s) throws IOException
JTextFieldreadObject and writeObject in
JComponent for more
information about serialization in Swing.
s - the ObjectOutputStream in which to write
IOExceptionprivate void setFormatterActions(Action[] actions)
actions.
private void setValue(Object value, boolean createFormat)
createFormat is true, this will also obtain
a new AbstractFormatter from the current
factory.
private void setEdited(boolean edited)
private boolean isEdited()
private javax.swing.JFormattedTextField.AbstractFormatterFactory getDefaultFormatterFactory(Object type)