- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.text.JTextComponent
-
- javax.swing.JTextField
-
- javax.swing.JFormattedTextField
-
- All Implemented Interfaces:
-
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable,SwingConstants
@JavaBean public class JFormattedTextField extends JTextField
JFormattedTextField扩展了JTextField增加了格式化任意值的支持,以及一旦用户编辑了文本,就检索了一个特定的对象。 以下说明配置JFormattedTextField编辑日期:JFormattedTextField ftf = new JFormattedTextField(); ftf.setValue(new Date());一旦创建了一个
JFormattedTextField,您可以通过添加PropertyChangeListener并监听PropertyChangeEvents的属性名称value来监听编辑更改。
Possible JFormattedTextField configurations and their descriptions Value Description JFormattedTextField.REVERT Revert the display to match that ofJFormattedTextField允许配置在丢失焦点时应采取的操作。 可能的配置是:getValue, possibly losing the current edit. JFormattedTextField.COMMIT Commits the current value. If the value being edited isn't considered a legal value by theAbstractFormatterthat is, aParseExceptionis thrown, then the value will not change, and then edited value will persist. JFormattedTextField.COMMIT_OR_REVERT Similar toCOMMIT, but if the value isn't legal, behave likeREVERT. JFormattedTextField.PERSIST Do nothing, don't obtain a newAbstractFormatter, and don't update the value.
默认值为JFormattedTextField.COMMIT_OR_REVERT,有关详细信息,请参阅setFocusLostBehavior(int)。JFormattedTextField允许焦点离开,即使当前编辑的值无效。 当JFormattedTextField是无效的编辑状态时,要锁定焦点,您可以附加一个InputVerifier。 以下代码片段显示了这样一个InputVerifier的潜在实现:public class FormattedTextFieldVerifier extends InputVerifier { public boolean verify(JComponent input) { if (input instanceof JFormattedTextField) { JFormattedTextField ftf = (JFormattedTextField)input; AbstractFormatter formatter = ftf.getFormatter(); if (formatter != null) { String text = ftf.getText(); try { formatter.stringToValue(text); return true; } catch (ParseException pe) { return false; } } } return true; } public boolean shouldYieldFocus(JComponent input) { return verify(input); } }或者,您可以调用
commitEdit,这也将提交值。JFormattedTextField没有做格式化它自身,而是格式通过一个实例进行JFormattedTextField.AbstractFormatter这是从实例获得JFormattedTextField.AbstractFormatterFactory。JFormattedTextField.AbstractFormatter实例在通过install方法激活时通知,此时JFormattedTextField.AbstractFormatter可以安装任何所需的,通常为DocumentFilter。 同样JFormattedTextField不再需要AbstractFormatter,它会调用uninstall。JFormattedTextField通常查询AbstractFormatterFactory为AbstractFormat在它获得或失去焦点。 虽然这可以根据焦点失去的政策而改变。 如果焦点失去的政策是JFormattedTextField.PERSIST和JFormattedTextField已被编辑,则AbstractFormatterFactory将不会被查询,直到该值被提交。 类似地,如果焦点丢失策略为JFormattedTextField.COMMIT并且从stringToValue抛出异常,则在焦点丢失或获得时将不会查询AbstractFormatterFactory。JFormattedTextField.AbstractFormatter还负责确定何时提交到JFormattedTextField值。 大约JFormattedTextField.AbstractFormatters将使每个编辑都可以使用新的值,而其他的则不会提交该值。 您可以通过调用commitEdit从当前的JFormattedTextField.AbstractFormatter获取当前值。commitEdit将在JFormattedTextField按下返回时被调用。如果一个
AbstractFormatterFactory尚未被明确设置,则将根据setValue被调用的值类型的Class进行设置(假设值为非空值)。 例如,在以下代码中,将创建适当的AbstractFormatterFactory和AbstractFormatter来处理数字格式:JFormattedTextField tf = new JFormattedTextField(); tf.setValue(100);警告:由于
AbstractFormatter将通常在DocumentFilter上安装Document,而NavigationFilter上的JFormattedTextField不应该自行安装。 如果这样做,您可能会看到奇怪的行为,因为AbstractFormatter的编辑策略将不会被执行。警告: Swing不是线程安全的。 有关详细信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,支持所有JavaBeans的长期存储已被添加到
java.beans包中。 请参阅XMLEncoder。- 从以下版本开始:
- 1.4
- 另请参见:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 static classJFormattedTextField.AbstractFormatterAbstractFormatter实例由JFormattedTextField用于处理从对象到字符串以及从字符串返回到对象的转换。static classJFormattedTextField.AbstractFormatterFactory的实例AbstractFormatterFactory用于通过JFormattedTextField获得的实例AbstractFormatter其进而用来格式的值。-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
-
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextField
-
-
Field Summary
Fields Modifier and Type Field 描述 static intCOMMIT常数确定当焦点丢失时,应调用commitEdit。static intCOMMIT_OR_REVERT常数确定当焦点丢失时,应调用commitEdit。static intPERSIST常数确定当焦点丢失时,编辑的值应该保留。static intREVERT常数确定当焦点丢失时,编辑值应恢复为JFormattedTextField上设置的当前值。-
Fields inherited from class java.awt.Component
accessibleContext, 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 class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
-
Fields inherited from class javax.swing.JTextField
notifyAction
-
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 描述 JFormattedTextField()创建一个JFormattedTextField,没有AbstractFormatterFactory。JFormattedTextField(Object value)创建一个具有指定值的JFormattedTextField。JFormattedTextField(Format format)创建一个JFormattedTextField。JFormattedTextField(JFormattedTextField.AbstractFormatter formatter)创建一个JFormattedTextField与指定的AbstractFormatter。JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory)创建一个JFormattedTextField与指定的AbstractFormatterFactory。JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory, Object currentValue)创建一个JFormattedTextField与指定的AbstractFormatterFactory和初始值。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 voidcommitEdit()强制从AbstractFormatter的当前值并设置为当前值。Action[]getActions()获取编辑器的命令列表。intgetFocusLostBehavior()返回焦点丢失时的行为。JFormattedTextField.AbstractFormattergetFormatter()返回用于格式化和解析当前值的AbstractFormatter。JFormattedTextField.AbstractFormatterFactorygetFormatterFactory()返回当前的AbstractFormatterFactory。StringgetUIClassID()获取UI的类ID。ObjectgetValue()返回最后一个有效值。protected voidinvalidEdit()当用户输入无效值时调用。booleanisEditValid()如果正在编辑的当前值有效,则返回true。protected voidprocessFocusEvent(FocusEvent e)处理任何焦点事件,如FocusEvent.FOCUS_GAINED或FocusEvent.FOCUS_LOST。protected voidprocessInputMethodEvent(InputMethodEvent e)处理任何输入法事件,如InputMethodEvent.INPUT_METHOD_TEXT_CHANGED或InputMethodEvent.CARET_POSITION_CHANGED。voidsetDocument(Document doc)将编辑器与文本文档相关联。voidsetFocusLostBehavior(int behavior)设置焦点丢失时的行为。protected voidsetFormatter(JFormattedTextField.AbstractFormatter format)设置当前的AbstractFormatter。voidsetFormatterFactory(JFormattedTextField.AbstractFormatterFactory tf)设置AbstractFormatterFactory。voidsetValue(Object value)设置将从当前AbstractFormatterFactory获取的AbstractFormatter格式化的值。-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, modelToView2D, moveCaretPosition, paste, print, print, print, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, viewToModel2D, write
-
Methods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setFont, setHorizontalAlignment, setScrollOffset
-
-
-
-
字段详细信息
-
COMMIT
public static final int COMMIT
常数确定当焦点丢失时,应调用commitEdit。 如果在提交新值时抛出一个ParseException,则该值将保持不变。
-
COMMIT_OR_REVERT
public static final int COMMIT_OR_REVERT
常数确定当焦点丢失时,应调用commitEdit。 如果在提交新值时抛出一个ParseException,则该值将被还原。
-
REVERT
public static final int REVERT
常数确定当焦点丢失时,编辑值应恢复为在JFormattedTextField设置的当前值。
-
PERSIST
public static final int PERSIST
常数确定当焦点丢失时,编辑的值应该保留。
-
-
构造方法详细信息
-
JFormattedTextField
public JFormattedTextField()
创建一个JFormattedTextField,没有AbstractFormatterFactory。 使用setMask或setFormatterFactory配置JFormattedTextField以编辑特定类型的值。
-
JFormattedTextField
public JFormattedTextField(Object value)
创建一个具有指定值的JFormattedTextField。 这将根据AbstractFormatterFactory的类型创建一个value。- 参数
-
value- JFormattedTextField的初始值
-
JFormattedTextField
public JFormattedTextField(Format format)
创建一个JFormattedTextField。format被包裹在一个适当的AbstractFormatter,然后包裹在一个AbstractFormatterFactory。- 参数
-
format- 用于查找AbstractFormatter的格式
-
JFormattedTextField
public JFormattedTextField(JFormattedTextField.AbstractFormatter formatter)
创建一个JFormattedTextField与指定的AbstractFormatter。 该AbstractFormatter被放置在一个AbstractFormatterFactory。- 参数
-
formatter- AbstractFormatter用于格式化。
-
JFormattedTextField
public JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory)
创建一个JFormattedTextField与指定的AbstractFormatterFactory。- 参数
-
factory- 用于格式化的AbstractFormatterFactory。
-
JFormattedTextField
public JFormattedTextField(JFormattedTextField.AbstractFormatterFactory factory, Object currentValue)
创建一个JFormattedTextField与指定的AbstractFormatterFactory和初始值。- 参数
-
factory-AbstractFormatterFactory用于格式化。 -
currentValue- 要使用的初始值
-
-
方法详细信息
-
setFocusLostBehavior
@BeanProperty(bound=false, enumerationValues={"JFormattedTextField.COMMIT","JFormattedTextField.COMMIT_OR_REVERT","JFormattedTextField.REVERT","JFormattedTextField.PERSIST"}, description="Behavior when component loses focus") public void setFocusLostBehavior(int behavior)
设置焦点丢失时的行为。 这将是一个JFormattedTextField.COMMIT_OR_REVERT,JFormattedTextField.REVERT,JFormattedTextField.COMMIT或者JFormattedTextField.PERSIST注意某些AbstractFormatter,因为它们发生S可推动变化,从而使该值将没有任何效果。如果传入的对象不是上述值之一,则会抛出一个
IllegalArgumentException。此属性的默认值为
JFormattedTextField.COMMIT_OR_REVERT。- 参数
-
behavior- 识别焦点丢失时的行为 - 异常
-
IllegalArgumentException- 如果行为不是已知值之一
-
getFocusLostBehavior
public int getFocusLostBehavior()
返回焦点丢失时的行为。 这将是一个COMMIT_OR_REVERT,COMMIT,REVERT或者PERSIST注意某些AbstractFormatter,因为它们发生S可推动变化,从而使该值将没有任何效果。- 结果
- 当焦点丢失时返回行为
-
setFormatterFactory
@BeanProperty(visualUpdate=true, description="AbstractFormatterFactory, responsible for returning an AbstractFormatter that can format the current value.") public void setFormatterFactory(JFormattedTextField.AbstractFormatterFactory tf)
设置AbstractFormatterFactory。AbstractFormatterFactory能够返回一个AbstractFormatter的实例,用于格式化显示的值,以及执行编辑策略。如果你还没有明确设置一个
AbstractFormatterFactory用此方法(或构造函数)的方式AbstractFormatterFactory,因此一个AbstractFormatter将根据使用Class的价值。NumberFormatter将用于Numbers,DateFormatter将用于Dates,否则将使用DefaultFormatter。这是一个JavaBeans绑定属性。
- 参数
-
tf-AbstractFormatterFactory用于查找AbstractFormatter实例
-
getFormatterFactory
public JFormattedTextField.AbstractFormatterFactory getFormatterFactory()
返回当前的AbstractFormatterFactory。- 结果
-
AbstractFormatterFactory用于确定AbstractFormatters - 另请参见:
-
setFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory)
-
setFormatter
protected void setFormatter(JFormattedTextField.AbstractFormatter format)
设置当前的AbstractFormatter。你通常不应该调用这个,而是设置
AbstractFormatterFactory或设置值。JFormattedTextField将调用此作为JFormattedTextField更改的状态,并要求重置该值。JFormattedTextField遍在AbstractFormatter从所获得的AbstractFormatterFactory。这是一个JavaBeans绑定属性。
- 参数
-
format- 用于格式化的抽象格式 - 另请参见:
-
setFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory)
-
getFormatter
@BeanProperty(visualUpdate=true, description="TextFormatter, responsible for formatting the current value") public JFormattedTextField.AbstractFormatter getFormatter()
返回用于格式化和解析当前值的AbstractFormatter。- 结果
- AbstractFormatter用于格式化
-
setValue
@BeanProperty(visualUpdate=true, description="The value to be formatted.") public void setValue(Object value)
设置将从当前AbstractFormatterFactory获取的AbstractFormatter格式化的值。 如果没有指定AbstractFormatterFactory,则将尝试根据value的类型创建一个。此属性的默认值为null。
这是一个JavaBeans绑定属性。
- 参数
-
value- 要显示的当前值
-
getValue
public Object getValue()
返回最后一个有效值。 根据AbstractFormatter的编辑策略,这可能不会返回当前值。 当前编辑的值可以通过调用commitEdit后跟getValue。- 结果
- 最后有效值
-
commitEdit
public void commitEdit() throws ParseException强制从AbstractFormatter的当前值并设置为当前值。 如果没有安装当前的AbstractFormatter,则AbstractFormatter。- 异常
-
ParseException- 如果AbstractFormatter无法格式化当前值
-
isEditValid
@BeanProperty(bound=false) public boolean isEditValid()
如果正在编辑的当前值有效,则返回true。 它的价值由当前的AbstractFormatter管理,因此没有公共设置者。- 结果
- 如果正在编辑的当前值有效,则为true。
-
invalidEdit
protected void invalidEdit()
当用户输入无效值时调用。 这使组件有机会提供反馈。 默认实现哔声。
-
processInputMethodEvent
protected void processInputMethodEvent(InputMethodEvent e)
处理任何输入法事件,如InputMethodEvent.INPUT_METHOD_TEXT_CHANGED或InputMethodEvent.CARET_POSITION_CHANGED。- 重写:
-
processInputMethodEvent在JTextComponent - 参数
-
e-InputMethodEvent - 另请参见:
-
InputMethodEvent
-
processFocusEvent
protected void processFocusEvent(FocusEvent e)
处理任何焦点事件,如FocusEvent.FOCUS_GAINED或FocusEvent.FOCUS_LOST。- 重写:
-
processFocusEvent在Component - 参数
-
e-FocusEvent - 另请参见:
-
FocusEvent
-
getActions
@BeanProperty(bound=false) public Action[] getActions()
获取编辑器的命令列表。 这是由编辑器本身支持的命令的集合所增加的插入UI支持的命令列表。 这些对绑定到事件是有用的,例如在键盘映射中。- 重写:
-
getActions在JTextField - 结果
- 命令列表
-
getUIClassID
@BeanProperty(bound=false) public String getUIClassID()
获取UI的类ID。- 重写:
-
getUIClassID在JTextField - 结果
- 字符串“FormattedTextFieldUI”
- 另请参见:
-
JComponent.getUIClassID()
-
setDocument
@BeanProperty(expert=true, description="the text document model") public void setDocument(Document doc)
将编辑器与文本文档相关联。 目前注册的工厂用于构建文档的视图,该文档在重新验证后由编辑器显示。 PropertyChange事件(“document”)被传播给每个监听器。- 重写:
-
setDocument在JTextField - 参数
-
doc- 要显示/编辑的文档 - 另请参见:
-
JTextComponent.getDocument()
-
-