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.
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.
addMouseListener(MouseListener)
- Adds a mouse listener.
addMouseMotionListener(MouseMotionListener)
- Adds a mouse motion listener.
createDefaultModel()
- Creates the default implementation of the model
to be used at construction if one isn't explicitly
given.
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.
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.
fireActionPerformed()
- Notifies all listeners that have registered interest for
notification on this event type.
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.
getScrollOffset()
- Gets the scroll offset.
getUIClassID()
- Gets the class ID for a UI.
paint(Graphics)
- Paints the component, translating the graphics by the scrolled amount
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.
removeMouseListener(MouseListener)
- Removes a mouse listener.
removeMouseMotionListener(MouseMotionListener)
- Removes a mouse motion listener.
repaint(long, int, int, int, int)
- Repaints the component, shifting by the scrolled amount
scrollRectToVisible(Rectangle)
- Scrolls the field left or right.
setColumns(int)
- Sets the number of columns in this TextField.
setFont(Font)
- Sets the current font.
setScrollOffset(int)
- Sets the scroll offset.
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.
getUIClassID
public String getUIClassID()
- Gets the class ID for a UI.
- Returns:
- the ID
- Overrides:
- getUIClassID in class JComponent
- See Also:
- getUIClassID, getUI
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 void addActionListener(ActionListener l)
- Adds the specified action listener to receive
action events from this textfield.
- Parameters:
- l - the action listener
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
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
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
getScrollOffset
public int getScrollOffset()
- Gets the scroll offset.
- Returns:
- the offset
setScrollOffset
public void setScrollOffset(int scrollOffset)
- Sets the scroll offset.
- Parameters:
- scrollOffset - the offset
scrollRectToVisible
public void scrollRectToVisible(Rectangle r)
- Scrolls the field left or right.
- Parameters:
- r - the region to scroll
- Overrides:
- scrollRectToVisible in class JComponent
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
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
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
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
addMouseListener
public void addMouseListener(MouseListener l)
- Adds a mouse listener.
- Parameters:
- l - the listener
- Overrides:
- addMouseListener in class Component
addMouseMotionListener
public void addMouseMotionListener(MouseMotionListener l)
- Adds a mouse motion listener.
- Parameters:
- l - the listener
- Overrides:
- addMouseMotionListener in class Component
removeMouseListener
public void removeMouseListener(MouseListener l)
- Removes a mouse listener.
- Parameters:
- l - the listener
- Overrides:
- removeMouseListener in class Component
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