Java javax.swing JTextField fields, constructors, methods, implement or subclass

Example usage for Java javax.swing JTextField fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for javax.swing JTextField.

The text is from its open source code.

Subclass

javax.swing.JTextField has subclasses.
Click this link to see all its subclasses.

Field

StringnotifyAction
Name of the action to send notification that the contents of the field have been accepted.

Constructor

JTextField(String text)
Constructs a new TextField initialized with the specified text.
JTextField(int columns)
Constructs a new empty TextField with the specified number of columns.
JTextField()
Constructs a new TextField.
JTextField(String text, int columns)
Constructs a new TextField initialized with the specified text and columns.
JTextField(Document doc, String text, int columns)
Constructs a new JTextField that uses the given text storage model and the given number of columns.

Method

Componentadd(Component comp)
Appends the specified component to the end of this container.
voidaddActionListener(ActionListener l)
Adds the specified action listener to receive action events from this textfield.
voidaddAncestorListener(AncestorListener listener)
Registers listener so that it will receive AncestorEvents when it or any of its ancestors move or are made visible or invisible.
voidaddCaretListener(CaretListener listener)
Adds a caret listener for notification of any changes to the caret.
voidaddFocusListener(FocusListener l)
Adds the specified focus listener to receive focus events from this component when this component gains input focus.
voidaddKeyListener(KeyListener l)
Adds the specified key listener to receive key events from this component.
voidaddMouseListener(MouseListener l)
Adds the specified mouse listener to receive mouse events from this component.
voidaddMouseMotionListener(MouseMotionListener l)
Adds the specified mouse motion listener to receive mouse motion events from this component.
voidaddPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list.
voidcopy()
Transfers the currently selected range in the associated text model to the system clipboard, leaving the contents in the text model.
voidcut()
Transfers the currently selected range in the associated text model to the system clipboard, removing the contents from the model.
AccessibleContextgetAccessibleContext()
Gets the AccessibleContext associated with this JTextField.
ActiongetAction()
Returns the currently set Action for this ActionEvent source, or null if no Action is set.
ActionListener[]getActionListeners()
Returns an array of all the ActionListeners added to this JTextField with addActionListener().
ActionMapgetActionMap()
Returns the ActionMap used to determine what Action to fire for particular KeyStroke binding.
Action[]getActions()
Fetches the command list for the editor.
ColorgetBackground()
Gets the background color of this component.
BordergetBorder()
Returns the border of this component or null if no border is currently set.
intgetCaretPosition()
Returns the position of the text insertion caret for the text component.
ObjectgetClientProperty(Object key)
Returns the value of the property with the specified key.
DocumentgetDocument()
Fetches the model associated with the editor.
FontgetFont()
Gets the font of this component.
FontMetricsgetFontMetrics(Font font)
Gets the FontMetrics for the specified Font.
ColorgetForeground()
Gets the foreground color of this component.
intgetHeight()
Returns the current height of this component.
intgetHorizontalAlignment()
Returns the horizontal alignment of the text.
BoundedRangeModelgetHorizontalVisibility()
Gets the visibility of the text field.
InputMapgetInputMap(int condition)
Returns the InputMap that is used during condition.
InputMapgetInputMap()
Returns the InputMap that is used when the component has focus.
KeymapgetKeymap()
Fetches the keymap currently active in this text component.
PointgetLocationOnScreen()
Gets the location of this component in the form of a point specifying the component's top-left corner in the screen's coordinate space.
StringgetName()
Gets the name of the component.
DimensiongetPreferredSize()
Returns the preferred size Dimensions needed for this TextField.
intgetScrollOffset()
Gets the scroll offset, in pixels.
StringgetSelectedText()
Returns the selected text contained in this TextComponent.
intgetSelectionEnd()
Returns the selected text's end position.
intgetSelectionStart()
Returns the selected text's start position.
StringgetText()
Returns the text contained in this TextComponent.
ToolkitgetToolkit()
Gets the toolkit of this component.
StringgetToolTipText()
Returns the tooltip string that has been set with setToolTipText.
ContainergetTopLevelAncestor()
Returns the top-level ancestor of this component (either the containing Window or Applet), or null if this component has not been added to any container.
intgetWidth()
Returns the current width of this component.
booleanhasFocus()
Returns true if this Component is the focus owner.
booleanisEnabled()
Determines whether this component is enabled.
booleanisOpaque()
Returns true if this component is completely opaque.
RectanglemodelToView(int pos)
Converts the given location in the model to a place in the view coordinate system.
voidpaste()
Transfers the contents of the system clipboard into the associated text model.
voidread(Reader in, Object desc)
Initializes from a stream.
voidregisterKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)
This method is now obsolete, please use a combination of getActionMap() and getInputMap() for similar behavior.
voidremoveKeyListener(KeyListener l)
Removes the specified key listener so that it no longer receives key events from this component.
voidrepaint()
Repaints this component.
voidreplaceSelection(String content)
Replaces the currently selected content with new content represented by the given string.
voidrequestFocus()
Requests that this Component gets the input focus.
booleanrequestFocusInWindow()
Requests that this Component gets the input focus.
voidrevalidate()
Supports deferred automatic layout.
voidselect(int selectionStart, int selectionEnd)
Selects the text between the specified start and end positions.
voidselectAll()
Selects all the text in the TextComponent.
voidsetAction(Action a)
Sets the Action for the ActionEvent source.
voidsetActionCommand(String command)
Sets the command string used for action events.
voidsetAlignmentX(float alignmentX)
Sets the horizontal alignment.
voidsetAutoscrolls(boolean autoscrolls)
Sets the autoscrolls property.
voidsetBackground(Color bg)
Sets the background color of this component.
voidsetBorder(Border border)
Sets the border of this component.
voidsetBounds(int x, int y, int width, int height)
Moves and resizes this component.
voidsetBounds(Rectangle r)
Moves and resizes this component to conform to the new bounding rectangle r .
voidsetCaret(Caret c)
Sets the caret to be used.
voidsetCaretPosition(int position)
Sets the position of the text insertion caret for the TextComponent.
voidsetColumns(int columns)
Sets the number of columns in this TextField, and then invalidate the layout.
voidsetComponentPopupMenu(JPopupMenu popup)
Sets the JPopupMenu for this JComponent.
voidsetDisabledTextColor(Color c)
Sets the current color used to render the disabled text.
voidsetDocument(Document doc)
Associates the editor with a text document.
voidsetDragEnabled(boolean b)
Turns on or off automatic drag handling.
voidsetEditable(boolean b)
Sets the specified boolean to indicate whether or not this TextComponent should be editable.
voidsetEnabled(boolean enabled)
Sets whether or not this component is enabled.
voidsetFocusable(boolean focusable)
Sets the focusable state of this Component to the specified value.
voidsetFocusAccelerator(char aKey)
Sets the key accelerator that will cause the receiving text component to get the focus.
voidsetFont(Font f)
Sets the current font.
voidsetForeground(Color fg)
Sets the foreground color of this component.
voidsetHorizontalAlignment(int alignment)
Sets the horizontal alignment of the text.
voidsetInheritsPopupMenu(boolean value)
Sets whether or not getComponentPopupMenu should delegate to the parent if this component does not have a JPopupMenu assigned to it.
voidsetInputVerifier(InputVerifier inputVerifier)
Sets the input verifier for this component.
voidsetLayout(LayoutManager mgr)
Sets the layout manager for this container.
voidsetLocation(int x, int y)
Moves this component to a new location.
voidsetMargin(Insets m)
Sets margin space between the text component's border and its text.
voidsetMaximumSize(Dimension maximumSize)
Sets the maximum size of this component to a constant value.
voidsetMinimumSize(Dimension minimumSize)
Sets the minimum size of this component to a constant value.
voidsetName(String name)
Sets the name of the component to the specified string.
voidsetNavigationFilter(NavigationFilter filter)
Sets the NavigationFilter.
voidsetOpaque(boolean isOpaque)
If true the component paints every pixel within its bounds.
voidsetPreferredSize(Dimension preferredSize)
Sets the preferred size of this component.
voidsetScrollOffset(int scrollOffset)
Sets the scroll offset, in pixels.
voidsetSelectionEnd(int selectionEnd)
Sets the selection end to the specified position.
voidsetSelectionStart(int selectionStart)
Sets the selection start to the specified position.
voidsetSize(int width, int height)
Resizes this component so that it has width width and height height .
voidsetSize(Dimension d)
Resizes this component so that it has width d.width and height d.height .
voidsetText(String t)
Sets the text of this TextComponent to the specified text.
voidsetToolTipText(String text)
Registers the text to display in a tool tip.
voidsetTransferHandler(TransferHandler newHandler)
Sets the TransferHandler , which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop.
voidsetVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget)
Sets the value to indicate whether input verifier for the current focus owner will be called before this component requests focus.
voidsetVisible(boolean aFlag)
Makes the component visible or invisible.
voidtransferFocus()
Transfers the focus to the next component, as though this Component were the focus owner.
intviewToModel(Point pt)
Converts the given place in the view coordinate system to the nearest representative location in the model.
voidwrite(Writer out)
Stores the contents of the model into the given stream.