All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class java.awt.swing.JTextField

java.lang.Object
    |
    +----java.awt.Component
            |
            +----java.awt.Container
                    |
                    +----java.awt.swing.JComponent
                            |
                            +----java.awt.swing.text.JTextComponent
                                    |
                                    +----java.awt.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 receive action events from this textfield.
 o addMouseListener(MouseListener)
Adds a mouse listener.
 o addMouseMotionListener(MouseMotionListener)
Adds a mouse motion listener.
 o createDefaultModel()
Creates the default implementation of the model to be used at construction if one isn't explicitly given.
 o createMouseListener()
Creates a mouse listener that listens to mouse events, shifting the event's x,y positions to the scrolled view translation, and refires them to any registered mouse listeners.
 o createMouseMotionListener()
Creates a mouse motion listener that listens to mouse events, shifting the event's x,y positions to the scrolled view translation, and refires them to any registered mouse listeners.
 o fireActionPerformed()
Notifies all listeners that have registered interest for notification on this event type.
 o getActions()
Fetches the command list for the editor.
 o getColumns()
Returns the number of columns in this TextField.
 o getColumnWidth()
Gets the column width.
 o getMinimumSize()
Returns the minimum size Dimensions needed for this TextField.
 o getPreferredSize()
Returns the preferred size Dimensions needed for this TextField.
 o getScrollOffset()
Gets the scroll offset.
 o getUIClassID()
Gets the class ID for a UI.
 o paint(Graphics)
Paints the component, translating the graphics by the scrolled amount
 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 removeMouseListener(MouseListener)
Removes a mouse listener.
 o removeMouseMotionListener(MouseMotionListener)
Removes a mouse motion listener.
 o repaint(long, int, int, int, int)
Repaints the component, shifting by the scrolled amount
 o scrollRectToVisible(Rectangle)
Scrolls the field left or right.
 o setColumns(int)
Sets the number of columns in this TextField.
 o setFont(Font)
Sets the current font.
 o setScrollOffset(int)
Sets the scroll offset.

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
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.

Methods

 o getUIClassID
public String getUIClassID()
Gets the class ID for a UI.

Returns:
the ID
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI
 o 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
 o getColumns
public int getColumns()
Returns the number of columns in this TextField.

Returns:
the number of columns
 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()
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
 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 width is set to the columns multiplied by the column width.

Returns:
the dimensions
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.

Returns:
the dimensions
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.

Parameters:
f - the new font
Overrides:
setFont in class Component
 o addActionListener
public void addActionListener(ActionListener l)
Adds the specified action listener to receive action events from this textfield.

Parameters:
l - the action listener
 o removeActionListener
public 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 fireActionPerformed
protected void fireActionPerformed()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList
 o 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
 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.

Returns:
the string of parameters
Overrides:
paramString in class Container
 o getScrollOffset
public int getScrollOffset()
Gets the scroll offset.

Returns:
the offset
 o setScrollOffset
public void setScrollOffset(int scrollOffset)
Sets the scroll offset.

Parameters:
scrollOffset - the offset
 o scrollRectToVisible
public void scrollRectToVisible(Rectangle r)
Scrolls the field left or right.

Parameters:
r - the region to scroll
Overrides:
scrollRectToVisible in class JComponent
 o repaint
public void repaint(long tm,
                    int x,
                    int y,
                    int width,
                    int height)
Repaints the component, shifting by the scrolled amount

Parameters:
tm - ???
x - the X coordinate
y - the Y coordinate
width - the width
height - the height
Overrides:
repaint in class JComponent
 o paint
public void paint(Graphics g)
Paints the component, translating the graphics by the scrolled amount

Parameters:
g - the graphics context
Overrides:
paint in class JComponent
 o createMouseListener
protected MouseListener createMouseListener()
Creates a mouse listener that listens to mouse events, shifting the event's x,y positions to the scrolled view translation, and refires them to any registered mouse listeners.

Returns:
the listener
 o createMouseMotionListener
protected MouseMotionListener createMouseMotionListener()
Creates a mouse motion listener that listens to mouse events, shifting the event's x,y positions to the scrolled view translation, and refires them to any registered mouse listeners.

Returns:
the listener
 o addMouseListener
public void addMouseListener(MouseListener l)
Adds a mouse listener.

Parameters:
l - the listener
Overrides:
addMouseListener in class Component
 o addMouseMotionListener
public void addMouseMotionListener(MouseMotionListener l)
Adds a mouse motion listener.

Parameters:
l - the listener
Overrides:
addMouseMotionListener in class Component
 o removeMouseListener
public void removeMouseListener(MouseListener l)
Removes a mouse listener.

Parameters:
l - the listener
Overrides:
removeMouseListener in class Component
 o removeMouseMotionListener
public void removeMouseMotionListener(MouseMotionListener l)
Removes a mouse motion listener.

Parameters:
l - the listener
Overrides:
removeMouseMotionListener in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Submit a bug or feature