- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.text.JTextComponent
-
- javax.swing.JTextField
-
- 实现的所有接口
-
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable,SwingConstants
@JavaBean(defaultProperty="UIClassID", description="A component which allows for the editing of a single line of text.") public class JTextField extends JTextComponent implements SwingConstants
JTextField是一个轻量级组件,允许编辑单行文本。 有关使用文本字段的信息和示例,请参阅The Java Tutorial中的 How to Use Text Fields 。JTextField旨在与java.awt.TextField源代码兼容,这样做是合理的。 此组件具有java.awt.TextField类中找不到的java.awt.TextField。 应该咨询超类以获得更多功能。JTextField有一个方法来建立用作被触发的动作事件的命令字符串的字符串。java.awt.TextField使用该字段的文本作为ActionEvent的命令字符串。JTextField将使用setActionCommand方法设置的命令字符串,如果不是null,否则它将使用该字段的文本作为与java.awt.TextField的兼容性。不直接提供方法
setEchoChar和getEchoChar以避免无意中暴露密码字符的可插入外观的新实现。 为了提供类似密码的服务,单独的类JPasswordField扩展了JTextField,以便为该服务提供独立可插拔的外观。该
java.awt.TextField可以更改通过添加一个被监控TextListener为TextEvent的。 在基于JTextComponent的组件中,通过DocumentEvent至DocumentListeners从模型广播变化。 如果需要,DocumentEvent给出了更改的位置和更改的类型。 代码片段可能类似于:DocumentListener myListener = ??; JTextField myArea = ??; myArea.getDocument().addDocumentListener(myListener);JTextField的水平对齐可以设置为左对齐,前导对齐,居中,右对齐或尾对齐。 如果字段文本的所需大小小于分配给它的大小,则右/尾对齐很有用。 这由setHorizontalAlignment和getHorizontalAlignment方法确定。 默认值是前导对齐。文本字段如何使用VK_ENTER事件取决于文本字段是否具有任何动作侦听器。 如果是这样,那么VK_ENTER会导致侦听器获得ActionEvent,并且消耗VK_ENTER事件。 这与AWT文本字段处理VK_ENTER事件的方式兼容。 如果文本字段没有动作侦听器,则从v 1.3开始,不会消耗VK_ENTER事件。 而是处理祖先组件的绑定,这使得JFC / Swing的默认按钮功能可以工作。
通过扩展模型并更改提供的默认模型,可以轻松创建自定义字段。 例如,以下代码段将创建仅包含大写字符的字段。 即使从剪贴板粘贴文本或通过程序更改更改文本,它也会起作用。
public class UpperCaseField extends JTextField { public UpperCaseField(int cols) { super(cols); } protected Document createDefaultModel() { return new UpperCaseDocument(); } static class UpperCaseDocument extends PlainDocument { public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (str == null) { return; } char[] upper = str.toCharArray(); for (int i = 0; i < upper.length; i++) { upper[i] = Character.toUpperCase(upper[i]); } super.insertString(offs, new String(upper), a); } } }警告: Swing不是线程安全的。 有关更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans软件包中添加了对所有JavaBeansjava.beans长期存储的支持。 请参阅XMLEncoder。- 从以下版本开始:
- 1.2
- 另请参见:
-
setActionCommand(java.lang.String),JPasswordField,addActionListener(java.awt.event.ActionListener), Serialized Form
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 protected classJTextField.AccessibleJTextField此类实现JTextField类的可访问性支持。-
嵌套类/接口声明在类 javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
-
嵌套类/接口声明在类 javax.swing.JComponent
JComponent.AccessibleJComponent
-
嵌套类/接口声明在类 java.awt.Container
Container.AccessibleAWTContainer
-
-
字段汇总
字段 变量和类型 字段 描述 static StringnotifyAction要发送通知的字段内容已被接受的操作的名称。-
声明的属性在类 javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
-
声明的属性在类 javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
声明的属性在类 java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Fields declared in 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
-
-
构造方法摘要
构造方法 构造器 描述 JTextField()构造一个新的TextField。JTextField(int columns)构造具有指定列数的新空TextField。JTextField(String text)构造一个使用指定文本初始化的新TextField。JTextField(String text, int columns)构造一个使用指定文本和列初始化的新TextField。JTextField(Document doc, String text, int columns)构造一个新的JTextField,它使用给定的文本存储模型和给定的列数。
-
方法摘要
所有方法 实例方法 具体的方法 变量和类型 方法 描述 protected voidactionPropertyChanged(Action action, String propertyName)更新文本字段的状态以响应关联操作中的属性更改。voidaddActionListener(ActionListener l)添加指定的操作侦听器以从此文本字段接收操作事件。protected voidconfigurePropertiesFromAction(Action a)设置此文本字段上的属性以匹配指定的Action中的Action。protected PropertyChangeListenercreateActionPropertyChangeListener(Action a)创建并返回一个PropertyChangeListener,负责监听指定的Action更改并更新相应的属性。protected DocumentcreateDefaultModel()如果没有明确给出,则创建要在构造中使用的模型的默认实现。protected voidfireActionPerformed()通知所有已注册对此事件类型的通知感兴趣的听众。AccessibleContextgetAccessibleContext()获取与AccessibleContext相关的JTextField。ActiongetAction()返回当前设置的Action这个ActionEvent来源,或null如果没有Action设置。ActionListener[]getActionListeners()返回使用addActionListener()添加到此JTextField的所有ActionListener的数组。Action[]getActions()获取编辑器的命令列表。intgetColumns()返回此TextField的列数。protected intgetColumnWidth()返回列宽。intgetHorizontalAlignment()返回文本的水平对齐方式。BoundedRangeModelgetHorizontalVisibility()获取文本字段的可见性。DimensiongetPreferredSize()返回此Dimensions所需的首选大小TextField。intgetScrollOffset()获取滚动偏移量(以像素为单位)。StringgetUIClassID()获取UI的类ID。booleanisValidateRoot()来自文本字段内的revalidate调用将通过验证文本字段来处理,除非文本字段包含在JViewport,在这种情况下,它返回false。protected StringparamString()返回此JTextField的字符串表示JTextField。voidpostActionEvent()处理在此文本字段上发生的操作事件,方法是将它们分派给任何已注册的ActionListener对象。voidremoveActionListener(ActionListener l)删除指定的操作侦听器,以便它不再从此文本字段接收操作事件。voidscrollRectToVisible(Rectangle r)向左或向右滚动字段。voidsetAction(Action a)设置Action为ActionEvent源。voidsetActionCommand(String command)设置用于操作事件的命令字符串。voidsetColumns(int columns)设置此TextField的列数,然后使布局无效。voidsetDocument(Document doc)将编辑器与文本文档关联。voidsetFont(Font f)设置当前字体。voidsetHorizontalAlignment(int alignment)设置文本的水平对齐方式。voidsetScrollOffset(int scrollOffset)设置滚动偏移(以像素为单位)。-
声明方法的类 javax.swing.text.JTextComponent
addCaretListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, 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, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, viewToModel2D, write
-
声明方法的类 javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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, 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, removeNotify, 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
-
声明方法的类 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
-
声明方法的类 java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
构造方法详细信息
-
JTextField
public JTextField()
构造一个新的TextField。 创建默认模型,初始字符串为null,列数设置为0。
-
JTextField
public JTextField(String text)
构造一个使用指定文本初始化的新TextField。 将创建默认模型,列数为0。- 参数
-
text- 要显示的文本,或null
-
JTextField
public JTextField(int columns)
构造具有指定列数的新空TextField。 将创建默认模型,并将初始字符串设置为null。- 参数
-
columns- 用于计算首选宽度的列数; 如果列设置为零,则首选宽度将是组件实现自然产生的任何宽度
-
JTextField
public JTextField(String text, int columns)
构造一个使用指定文本和列初始化的新TextField。 创建默认模型。- 参数
-
text- 要显示的文本,或null -
columns- 用于计算首选宽度的列数; 如果列设置为零,则首选宽度将是组件实现自然产生的任何宽度
-
JTextField
public JTextField(Document doc, String text, int columns)
构造一个新的JTextField,它使用给定的文本存储模型和给定的列数。 这是其他构造函数通过其提供的构造函数。 如果文档是null,则创建默认模型。- 参数
-
doc- 要使用的文本存储; 如果这是null,则通过调用createDefaultModel方法提供默认值 -
text- 要显示的初始字符串,或null -
columns- 用于计算首选宽度的列数> = 0; 如果columns设置为零,则首选宽度将是组件实现自然产生的任何宽度 - 异常
-
IllegalArgumentException- 如果columns<0
-
-
方法详细信息
-
getUIClassID
@BeanProperty(bound=false) public String getUIClassID()
获取UI的类ID。- 重写:
-
getUIClassID在类JComponent - 结果
- 字符串“TextFieldUI”
- 另请参见:
-
JComponent.getUIClassID(),UIDefaults.getUI(javax.swing.JComponent)
-
setDocument
@BeanProperty(expert=true, description="the text document model") public void setDocument(Document doc)
将编辑器与文本文档关联。 当前注册的工厂用于构建文档的视图,在重新验证后由编辑器显示。 PropertyChange事件(“document”)传播到每个侦听器。- 重写:
-
setDocument在类JTextComponent - 参数
-
doc- 要显示/编辑的文档 - 另请参见:
-
JTextComponent.getDocument()
-
isValidateRoot
public boolean isValidateRoot()
来自文本字段内的revalidate调用将通过验证文本字段来处理,除非文本字段包含在JViewport,在这种情况下,它返回false。- 重写:
-
isValidateRoot在类JComponent - 结果
-
如果此textfield的父级是
JViewPort返回false,否则返回true - 另请参见:
-
JComponent.revalidate(),JComponent.isValidateRoot(),Container.isValidateRoot()
-
getHorizontalAlignment
public int getHorizontalAlignment()
返回文本的水平对齐方式。 有效密钥是:-
JTextField.LEFT -
JTextField.CENTER -
JTextField.RIGHT -
JTextField.LEADING -
JTextField.TRAILING
- 结果
- 水平对齐
-
-
setHorizontalAlignment
@BeanProperty(preferred=true, enumerationValues={"JTextField.LEFT","JTextField.CENTER","JTextField.RIGHT","JTextField.LEADING","JTextField.TRAILING"}, description="Set the field alignment to LEFT, CENTER, RIGHT, LEADING (the default) or TRAILING") public void setHorizontalAlignment(int alignment)
设置文本的水平对齐方式。 有效密钥是:-
JTextField.LEFT -
JTextField.CENTER -
JTextField.RIGHT -
JTextField.LEADING -
JTextField.TRAILING
invalidate和repaint,并PropertyChange事件(“horizontalAlignment”)。- 参数
-
alignment- 对齐方式 - 异常
-
IllegalArgumentException- 如果alignment不是有效密钥
-
-
createDefaultModel
protected Document createDefaultModel()
如果没有明确给出,则创建要在构造中使用的模型的默认实现。 返回PlainDocument的实例。- 结果
- 默认的模型实现
-
getColumns
public int getColumns()
返回此TextField的列数。- 结果
- 列数> = 0
-
setColumns
@BeanProperty(bound=false, description="the number of columns preferred for display") public void setColumns(int columns)
设置此TextField的列数,然后使布局无效。- 参数
-
columns- 列数> = 0 - 异常
-
IllegalArgumentException- 如果columns小于0
-
getColumnWidth
protected int getColumnWidth()
返回列宽。 对于某些字体,列的含义可以被认为是相当弱的概念。 此方法用于定义列的宽度。 默认情况下,它被定义为所用字体的字符m的宽度。 可以将此方法重新定义为某个替代数量- 结果
- 列宽> = 1
-
getPreferredSize
public Dimension getPreferredSize()
返回此Dimensions所需的首选大小TextField。 如果已设置非零数量的列,则将宽度设置为列乘以列宽。- 重写:
-
getPreferredSize在类JComponent - 结果
- 这个文本域的维度
- 另请参见:
-
JComponent.setPreferredSize(java.awt.Dimension),ComponentUI
-
setFont
public void setFont(Font f)
设置当前字体。 这将删除缓存的行高和列宽,以便反映新字体。 设置字体后调用revalidate。- 重写:
-
setFont在类JComponent - 参数
-
f- 新字体 - 另请参见:
-
Component.getFont()
-
addActionListener
public void addActionListener(ActionListener l)
添加指定的操作侦听器以从此文本字段接收操作事件。- 参数
-
l- 要添加的动作侦听器
-
removeActionListener
public void removeActionListener(ActionListener l)
删除指定的操作侦听器,以便它不再从此文本字段接收操作事件。- 参数
-
l- 要删除的动作侦听器
-
getActionListeners
@BeanProperty(bound=false) public ActionListener[] getActionListeners()
返回使用addActionListener()添加到此JTextField的所有ActionListener的数组。- 结果
-
添加了所有
ActionListener或如果没有添加侦听器则为空数组 - 从以下版本开始:
- 1.4
-
fireActionPerformed
protected void fireActionPerformed()
通知所有已注册对此事件类型的通知感兴趣的听众。 事件实例是懒惰创建的。 侦听器列表按最后一个顺序处理。- 另请参见:
-
EventListenerList
-
setActionCommand
public void setActionCommand(String command)
设置用于操作事件的命令字符串。- 参数
-
command- 命令字符串
-
setAction
@BeanProperty(visualUpdate=true, description="the Action instance connected with this ActionEvent source") public void setAction(Action a)
设置Action为ActionEvent源。 新的Action取代之前设置的任何Action但不影响ActionListeners独立添加addActionListener。 如果Action已经是ActionEvent源的注册ActionListener,则不会重新注册。设置
Action结果立即改变中描述的所有属性Swing Components SupportingAction。 随后,当Action的属性发生变化时,文本字段的属性会自动更新。此方法使用其他三种方法来设置和帮助跟踪
Action的属性值。 它使用configurePropertiesFromAction方法立即更改文本字段的属性。 要跟踪Action属性值中的更改,此方法将注册PropertyChangeListener返回的createActionPropertyChangeListener。 默认PropertyChangeListener调用actionPropertyChanged方法时的属性Action变化。- 参数
-
a-Action的JTextField或null - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,getAction(),configurePropertiesFromAction(javax.swing.Action),createActionPropertyChangeListener(javax.swing.Action),actionPropertyChanged(javax.swing.Action, java.lang.String)
-
getAction
public Action getAction()
返回当前设置的Action这个ActionEvent来源,或null如果没有Action设置。- 结果
-
Action用于此ActionEvent源,或null - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,setAction(javax.swing.Action)
-
configurePropertiesFromAction
protected void configurePropertiesFromAction(Action a)
设置此文本字段上的属性以匹配指定的Action中的Action。 有关此设置的属性的详细信息,请参阅Swing Components SupportingAction。- 参数
-
a- 从Action获取房产,或null - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,setAction(javax.swing.Action)
-
actionPropertyChanged
protected void actionPropertyChanged(Action action, String propertyName)
更新文本字段的状态以响应关联操作中的属性更改。 从PropertyChangeListener返回的createActionPropertyChangeListener调用此方法。 子类通常不需要调用它。 支持其他Action属性的子类应覆盖此和configurePropertiesFromAction。有关此方法设置的属性列表,请参阅表Swing Components Supporting
Action。- 参数
-
action- 与Action本Action关联的Action -
propertyName- 已更改的属性的名称 - 从以下版本开始:
- 1.6
- 另请参见:
-
Action,configurePropertiesFromAction(javax.swing.Action)
-
createActionPropertyChangeListener
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
创建并返回一个PropertyChangeListener,负责监听指定的Action更改并更新相应的属性。警告:如果你是子类,则不要创建匿名内部类。 如果你这样做,文本字段的生命周期将与
Action的生命周期相关Action。- 参数
-
a- 文本字段的操作 - 结果
-
PropertyChangeListener,负责监听指定的Action更改并更新相应的属性 - 从以下版本开始:
- 1.3
- 另请参见:
-
Action,setAction(javax.swing.Action)
-
getActions
@BeanProperty(bound=false) public Action[] getActions()
获取编辑器的命令列表。 这是插件UI支持的命令列表,由编辑器本身支持的命令集合增强。 这些对于绑定事件很有用,例如在键映射中。- 重写:
-
getActions在类JTextComponent - 结果
- 命令列表
-
postActionEvent
public void postActionEvent()
处理在此文本字段上发生的操作事件,方法是将它们分派给任何已注册的ActionListener对象。 这通常由注册了textfield的控制器调用。
-
getHorizontalVisibility
@BeanProperty(bound=false) public BoundedRangeModel getHorizontalVisibility()
获取文本字段的可见性。 如果字段的大小大于分配给字段的区域,则可以调整此值以更改可见区域的位置。字段外观实现管理
BoundedRangeModel上的最小值,最大值和范围属性的BoundedRangeModel。- 结果
- 能见度
- 另请参见:
-
BoundedRangeModel
-
getScrollOffset
public int getScrollOffset()
获取滚动偏移量(以像素为单位)。- 结果
- 偏移> = 0
-
setScrollOffset
public void setScrollOffset(int scrollOffset)
设置滚动偏移(以像素为单位)。- 参数
-
scrollOffset- 偏移量> = 0
-
scrollRectToVisible
public void scrollRectToVisible(Rectangle r)
向左或向右滚动字段。- 重写:
-
scrollRectToVisible在类JComponent - 参数
-
r- 要滚动的区域 - 另请参见:
-
JViewport
-
paramString
protected String paramString()
返回此JTextField的字符串表示JTextField。 此方法仅用于调试目的,返回字符串的内容和格式可能因实现而异。 返回的字符串可能为空,但可能不是null。- 重写:
-
paramString在类JTextComponent - 结果
-
此
JTextField的字符串表示JTextField
-
getAccessibleContext
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()
获取AccessibleContext与此相关JTextField。 为JTextFields,所述AccessibleContext需要一个的形式AccessibleJTextField。 如有必要,将创建一个新的AccessibleJTextField实例。- Specified by:
-
getAccessibleContext,界面Accessible - 重写:
-
getAccessibleContext在类JTextComponent - 结果
-
an
AccessibleJTextFieldthat serves as theAccessibleContextof thisJTextField
-
-