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.
-
notifyAction
- Name of the action to send notification that the
contents of the field have been accepted.
-
JTextField()
- Constructs a new TextField.
-
JTextField(Document, String, int)
- Constructs a new JTextField that uses the given text storage
model and the given number of columns.
-
JTextField(int)
- Constructs a new empty TextField with the specified number of columns.
-
JTextField(String)
- Constructs a new TextField initialized with the specified text.
-
JTextField(String, int)
- Constructs a new TextField initialized with the specified text
and columns.
-
addActionListener(ActionListener)
- Adds the specified action listener to receive
action events from this textfield.
-
createDefaultModel()
- Creates the default implementation of the model
to be used at construction if one isn't explicitly
given.
-
getActions()
- Fetches the command list for the editor.
-
getColumns()
- Returns the number of columns in this TextField.
-
getColumnWidth()
- Gets the column width.
-
getMinimumSize()
- Returns the minimum size Dimensions needed for this
TextField.
-
getPreferredSize()
- Returns the preferred size Dimensions needed for this
TextField.
-
paramString()
- Returns the String of parameters for this JTextField.
-
postActionEvent()
-
Processes action events occurring on this textfield by
dispatching them to any registered ActionListener objects.
-
removeActionListener(ActionListener)
- Removes the specified action listener so that it no longer
receives action events from this textfield.
-
setActionCommand(String)
- Sets the command string used for action events.
-
setColumns(int)
- Sets the number of columns in this TextField.
-
setFont(Font)
- Sets the current font.
-
updateUI()
- Reloads the pluggable UI.
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.
JTextField
public JTextField()
- Constructs a new TextField.
JTextField
public JTextField(String text)
- Constructs a new TextField initialized with the specified text.
- Parameters:
- text - the text to be displayed
JTextField
public JTextField(int columns)
- Constructs a new empty TextField with the specified number of columns.
- Parameters:
- columns - the number of columns
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
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
- text - the initial string to display
- 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.
updateUI
public void updateUI()
- Reloads the pluggable UI. The key used to fetch the
new interface is TextFieldUI.
- Overrides:
- updateUI in class JComponent
createDefaultModel
protected Document createDefaultModel()
- Creates the default implementation of the model
to be used at construction if one isn't explicitly
given.
- Returns:
- the default model implementation
getColumns
public int getColumns()
- Returns the number of columns in this TextField.
- Returns:
- the number of columns
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
getColumnWidth
protected int getColumnWidth()
- Gets the column width.
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
- Returns:
- the column width
getPreferredSize
public Dimension getPreferredSize()
- Returns the preferred size Dimensions needed for this
TextField. If a non-zero number of columns has been
set, the width is set to the columns multiplied by
the column width.
- Returns:
- the dimensions
- Overrides:
- getPreferredSize in class JComponent
getMinimumSize
public Dimension getMinimumSize()
- Returns the minimum size Dimensions needed for this
TextField. This defaults to the preferred size.
- Returns:
- the dimensions
- Overrides:
- getMinimumSize in class JComponent
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.
- Parameters:
- f - the new font
- Overrides:
- setFont in class Component
addActionListener
public synchronized void addActionListener(ActionListener l)
- Adds the specified action listener to receive
action events from this textfield.
- Parameters:
- l - the action listener
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
setActionCommand
public void setActionCommand(String command)
- Sets the command string used for action events.
- Parameters:
- command - the command string
getActions
public Action[] getActions()
- Fetches 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.
- Returns:
- the command list
- Overrides:
- getActions in class JTextComponent
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.
paramString
protected String paramString()
- Returns the String of parameters for this JTextField.
- Returns:
- the string of parameters
- Overrides:
- paramString in class Container
All Packages Class Hierarchy This Package Previous Next Index