- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.text.JTextComponent
-
- javax.swing.JTextField
-
- All Implemented Interfaces:
-
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是一个轻量级组件,允许编辑单行文本。 有关使用文本字段的信息和示例,请参阅Java教程中的 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,为这项服务提供了独立可插拔的外观。可以通过为
TextEvent添加一个TextListener来监视java.awt.TextField的更改。 在基于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开始,支持所有JavaBeans的长期存储已被添加到
java.beans包中。 请参阅XMLEncoder。- 从以下版本开始:
- 1.2
- 另请参见:
-
setActionCommand(java.lang.String),JPasswordField,addActionListener(java.awt.event.ActionListener), Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 protected classJTextField.AccessibleJTextField该类为JTextField类实现可访问性支持。-
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
-
-
Field Summary
Fields Modifier and Type Field 描述 static StringnotifyAction要发送通知的操作的名称,该字段的内容已被接受。-
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 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 描述 JTextField()构造新的TextField。JTextField(int columns)构造一个新的空的TextField具有指定的列数。JTextField(String text)构造一个新的TextField,用指定的文本初始化。JTextField(String text, int columns)构造一个新的TextField,用指定的文本和列初始化。JTextField(Document doc, String text, int columns)构造一个新的JTextField,它使用给定的文本存储模型和给定的列数。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 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来处理来自textfield本身的JViewport,除非textfield包含在一个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)设置滚动偏移量,以像素为单位。-
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, processFocusEvent, 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, processInputMethodEvent, 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
-
-
-
-
字段详细信息
-
notifyAction
public static final String notifyAction
要发送通知的操作的名称,该字段的内容已被接受。 通常这是绑定回车。- 另请参见:
- Constant Field Values
-
-
构造方法详细信息
-
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()
来自textfield本身的revalidate调用将通过验证文本字段来处理,除非textfield包含在一个JViewport,在这种情况下返回false。- 重写:
-
isValidateRoot在JComponent - 结果
-
如果这个文本
JViewPort的父对象是一个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已经注册了ActionListener的ActionEvent来源,则不会重新注册。设置
Action结果立即改变中描述的所有属性Swing Components SupportingAction。 随后,随着Action的属性更改,Action的属性将自动更新。该方法使用三种其他方法设置和帮助跟踪
Action的属性值。 它使用configurePropertiesFromAction方法立即更改文本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,或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 -
propertyName- 更改的属性的名称 - 从以下版本开始:
- 1.6
- 另请参见:
-
Action,configurePropertiesFromAction(javax.swing.Action)
-
createActionPropertyChangeListener
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
创建并返回一个PropertyChangeListener,负责监听从指定的Action进行的更改并更新相应的属性。警告:如果你这个子类不创建一个匿名的内部类。 如果你这样做的生活中的textfield将被绑定到
Action。- 参数
-
a- 文本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对象来处理在此文本字段上发生的操作事件。 这通常由注册在文本域中的控制器调用。
-
getHorizontalVisibility
@BeanProperty(bound=false) public BoundedRangeModel getHorizontalVisibility()
获取文本字段的可见性。 如果字段的大小大于分配给该字段的区域,则可以调整此位置以更改可见区域的位置。字段外观实现管理
BoundedRangeModel的最小值,最大值和范围属性的BoundedRangeModel。- 结果
- 能见度
- 另请参见:
-
BoundedRangeModel
-
getScrollOffset
public int getScrollOffset()
获取滚动偏移量,以像素为单位。- 结果
- offset> = 0
-
setScrollOffset
public void setScrollOffset(int scrollOffset)
设置滚动偏移量,以像素为单位。- 参数
-
scrollOffset- offset> = 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
-
-