All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.java.swing.JTextField

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.text.JTextComponent
                                   |
                                   +----com.sun.java.swing.JTextField

public class JTextField
extends JTextComponent
JTextField is a lightweight component that allows the editing of a single line of text. It is intended to be source-compatible with java.awt.TextField where it is reasonable to do so.


Variable Index

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

Constructor Index

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

Method Index

 o addActionListener(ActionListener)
Adds the specified action listener to recieve action events from this textfield.
 o createDefaultModel()
Creates the default implementation of the model to be used at construction if one isn't explicitly given.
 o getActions()
Fetch the command list for the editor.
 o getColumns()
Returns the number of columns in this TextField.
 o getColumnWidth()
The meaning of what a column is can be considered a fairly weak notion for some fonts.
 o getMinimumSize()
Returns the minimum size Dimensions needed for this TextField.
 o getPreferredSize()
Returns the preferred size Dimensions needed for this TextField.
 o paramString()
Returns the String of parameters for this JTextField.
 o postActionEvent()
Processes action events occurring on this textfield by dispatching them to any registered ActionListener objects.
 o removeActionListener(ActionListener)
Removes the specified action listener so that it no longer receives action events from this textfield.
 o setActionCommand(String)
Sets the command string used for action events.
 o setColumns(int)
Sets the number of columns in this TextField.
 o setFont(Font)
Sets the current font.
 o updateUI()
Reload the pluggable UI.

Variables

 o notifyAction
 public static final String notifyAction
Name of the action to send notification that the contents of the field have been accepted. Typically this is bound to a carriage-return.

Constructors

 o JTextField
 public JTextField()
Constructs a new TextField.

 o JTextField
 public JTextField(String text)
Constructs a new TextField initialized with the specified text.

Parameters:
text - the text to be displayed
 o JTextField
 public JTextField(int columns)
Constructs a new empty TextField with the specified number of columns.

Parameters:
columns - the number of columns
 o JTextField
 public JTextField(String text,
                   int columns)
Constructs a new TextField initialized with the specified text and columns.

Parameters:
text - the text to be displayed
columns - the number of columns
 o JTextField
 public JTextField(Document doc,
                   String text,
                   int columns)
Constructs a new JTextField that uses the given text storage model and the given number of columns. This is the constructor through which the other constructors feed.

Parameters:
doc - The text storage to use.
columns - The number of columns to use to calculate the preferred width. If columns is set to zero, the preferred width will be whatever naturally results from the component implementation.
text - The initial string to display.

Methods

 o updateUI
 public void updateUI()
Reload the pluggable UI. The key used to fetch the new interface is TextFieldUI.

Overrides:
updateUI in class JComponent
 o createDefaultModel
 protected Document createDefaultModel()
Creates the default implementation of the model to be used at construction if one isn't explicitly given.

 o getColumns
 public int getColumns()
Returns the number of columns in this TextField.

 o setColumns
 public void setColumns(int columns)
Sets the number of columns in this TextField.

Parameters:
columns - the number of columns
Throws: IllegalArgumentException
If columns is less than 0.
 o getColumnWidth
 protected int getColumnWidth()
The meaning of what a column is can be considered a fairly weak notion for some fonts. This method is used to define the width of a column. By default this is defined to be the width of the character m for the font used. This method can be redefined to be some alternative amount

 o getPreferredSize
 public Dimension getPreferredSize()
Returns the preferred size Dimensions needed for this TextField. If a non-zero number of columns has been set, the

Overrides:
getPreferredSize in class JComponent
 o getMinimumSize
 public Dimension getMinimumSize()
Returns the minimum size Dimensions needed for this TextField. This defaults to the preferred size.

Overrides:
getMinimumSize in class JComponent
 o setFont
 public void setFont(Font f)
Sets the current font. This removes cached row height and column width so the new font will be reflected.

Overrides:
setFont in class Component
 o addActionListener
 public synchronized void addActionListener(ActionListener l)
Adds the specified action listener to recieve action events from this textfield.

Parameters:
l - the action listener
 o removeActionListener
 public synchronized void removeActionListener(ActionListener l)
Removes the specified action listener so that it no longer receives action events from this textfield.

Parameters:
l - the action listener
 o setActionCommand
 public void setActionCommand(String command)
Sets the command string used for action events.

 o getActions
 public Action[] getActions()
Fetch the command list for the editor. This is the list of commands supported by the plugged-in UI augmented by the collection of commands that the editor itself supports. These are useful for binding to events, such as in a keymap.

Overrides:
getActions in class JTextComponent
 o postActionEvent
 public void postActionEvent()
Processes action events occurring on this textfield by dispatching them to any registered ActionListener objects. This is normally called by the controller registered with textfield.

 o paramString
 protected String paramString()
Returns the String of parameters for this JTextField.

Overrides:
paramString in class Container

All Packages  Class Hierarchy  This Package  Previous  Next  Index