Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Component
java.awt.TextComponent
java.awt.TextField
public class TextField
extends TextComponent
Nested Class Summary | |
protected class |
Nested classes/interfaces inherited from class java.awt.TextComponent | |
TextComponent.AccessibleAWTTextComponent |
Nested classes/interfaces inherited from class java.awt.Component | |
Component.AccessibleAWTComponent , Component.BltBufferStrategy , Component.FlipBufferStrategy |
Field Summary |
Fields inherited from class java.awt.TextComponent | |
textListener |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT , CENTER_ALIGNMENT , LEFT_ALIGNMENT , RIGHT_ALIGNMENT , TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver | |
ABORT , ALLBITS , ERROR , FRAMEBITS , HEIGHT , PROPERTIES , SOMEBITS , WIDTH |
Constructor Summary | |
| |
| |
Method Summary | |
void |
|
void |
|
boolean |
|
|
|
AccessibleContext |
|
ActionListener[] |
|
int |
|
char |
|
Dimension |
|
Dimension |
|
Dimension |
|
Dimension |
|
Dimension |
|
Dimension |
|
protected String |
|
Dimension |
|
Dimension |
|
protected void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public TextField()
Initializes a new instance ofTextField
that is empty and has one column.
- Throws:
HeadlessException
- If GraphicsEnvironment.isHeadless() is true,
public TextField(int columns)
Initializes a new instance ofTextField
that is empty and has the specified number of columns.
- Parameters:
columns
- The number of columns in the text field.
- Throws:
HeadlessException
- If GraphicsEnvironment.isHeadless() is true,
public TextField(String text)
Initializes a new instance ofTextField
containing the specified text. The number of columns will be equal to the length of the text string.
- Parameters:
text
- The text to display in the field.
- Throws:
HeadlessException
- If GraphicsEnvironment.isHeadless() is true,
public TextField(String text, int columns)
Initializes a new instance ofTextField
with the specified text and number of columns.
- Parameters:
text
- The text to display in the field.columns
- The number of columns in the field.
- Throws:
HeadlessException
- If GraphicsEnvironment.isHeadless() is true,
public void addActionListener(ActionListener listener)
Addes a new listener to the list of action listeners for this object.
- Parameters:
listener
- The listener to add to the list.
public boolean echoCharIsSet()
Tests whether or not this text field has an echo character set so that characters the user type are not echoed to the screen.
- Returns:
true
if an echo character is set,false
otherwise.
publicextends EventListener> T[] getListeners (ClasslistenerType)
Returns an array of all the objects currently registered as FooListeners upon thisTextField
. FooListeners are registered using the addFooListener method.
- Overrides:
- extends EventListener> T[] getListeners in interface TextComponent
- Throws:
ClassCastException
- If listenerType doesn't specify a class or interface that implements java.util.EventListener.
- Since:
- 1.3
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with thisTextComponent
. The context is created, if necessary.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface TextComponent
- Returns:
- the associated context
public ActionListener[] getActionListeners()
Return all ActionListeners register to thisTextField
object as an array.
- Since:
- 1.4
public int getColumns()
Returns the number of columns in the field.
- Returns:
- The number of columns in the field.
public char getEchoChar()
Returns the character that is echoed to the screen when a text field is protected (such as when a password is being entered).
- Returns:
- The echo character for this text field.
public Dimension getMinimumSize()
Returns the minimum size for this text field.
- Overrides:
- getMinimumSize in interface Component
- Returns:
- The minimum size for this text field.
public Dimension getMinimumSize(int columns)
Returns the minimum size of a text field with the specified number of columns.
- Parameters:
columns
- The number of columns to get the minimum size for.
public Dimension getPreferredSize()
Returns the preferred size for this text field.
- Overrides:
- getPreferredSize in interface Component
- Returns:
- The preferred size for this text field.
public Dimension getPreferredSize(int columns)
Returns the preferred size of a text field with the specified number of columns.
- Parameters:
columns
- The number of columns to get the preferred size for.
public Dimension minimumSize()
Deprecated. This method is deprecated in favor of
getMinimumSize()
.Returns the minimum size for this text field.
- Overrides:
- minimumSize in interface Component
- Returns:
- The minimum size for this text field.
public Dimension minimumSize(int columns)
Deprecated. This method is deprecated in favor of
getMinimumSize(int)
.Returns the minimum size of a text field with the specified number of columns.
- Parameters:
columns
- The number of columns to get the minimum size for.
protected String paramString()
Returns a debug string for this object.
- Overrides:
- paramString in interface TextComponent
- Returns:
- A debug string for this object.
public Dimension preferredSize()
Deprecated. This method is deprecated in favor of
getPreferredSize()
.Returns the preferred size for this text field.
- Overrides:
- preferredSize in interface Component
- Returns:
- The preferred size for this text field.
public Dimension preferredSize(int columns)
Deprecated. This method is deprecated in favor of
getPreferredSize(int)
.Returns the preferred size of a text field with the specified number of columns.
- Parameters:
columns
- The number of columns to get the preferred size for.
protected void processActionEvent(ActionEvent event)
Processes an action event by calling any registered listeners. Note to subclasses: This method is not called unless action events are enabled on this object. This will be true if any listeners are registered, or if action events were specifically enabled usingenableEvents()
.
- Parameters:
event
- The event to process.
protected void processEvent(AWTEvent event)
Processes the specified event. If the event is an instance ofActionEvent
thenprocessActionEvent()
is called to process it, otherwise the event is sent to the superclass.
- Overrides:
- processEvent in interface TextComponent
- Parameters:
event
- The event to process.
public void removeActionListener(ActionListener listener)
Removes the specified listener from the list of action listeners for this object.
- Parameters:
listener
- The listener to remove from the list.
public void setColumns(int columns)
Sets the number of columns in this field to the specified value.
- Parameters:
columns
- The new number of columns in the field.
- Throws:
IllegalArgumentException
- If columns is less than zero.
public void setEchoChar(char echoChar)
Sets the character that is echoed when protected input such as a password is displayed.
- Parameters:
echoChar
- The new echo character.
public void setEchoCharacter(char echoChar)
Deprecated. This method is deprecated in favor of
setEchoChar()
Sets the character that is echoed when protected input such as a password is displayed.
- Parameters:
echoChar
- The new echo character.