java::awt::TextField Class Reference

Inheritance diagram for java::awt::TextField:

Inheritance graph
java::awt::TextComponentjava::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::TextSourcejava::lang::Lockjava::lang::ScopeAdapterjava::awt::image::ImageObserverjava::util::EventSource
[legend]
Collaboration diagram for java::awt::TextField:

Collaboration graph
java::awt::TextComponentjava::awt::Componentjava::lang::Objectjava::lang::Interfacejava::lang::ObjectRefjava::lang::Syncjava::awt::event::ComponentSourcejava::awt::event::FocusSourcejava::awt::event::HierarchySourcejava::awt::event::KeySourcejava::awt::event::MouseSourcejava::awt::event::PaintSourcejava::util::PropertyChangeSourcejava::awt::event::TextSourcejava::lang::Lockjava::lang::ScopeAdapterjava::lang::Comparablejava::awt::image::ImageObserverjava::util::EventSourcejava::util::Collectionjava::util::LinkedListjava::util::AbstractSequentialListjava::util::AbstractListjava::util::AbstractCollectionjava::util::List
[legend]

List of all members.


Detailed Description

A TextField object is a text component that allows for the editing of a single line of text.

For example, the following image depicts a frame with four text fields of varying widths. Two of these text fields display the predefined text "Hello".

TextField-1.gif

Here is the code that produces these four text fields:


<blockquote>
 TextField tf1, tf2, tf3, tf4;
 // a blank text field
 tf1 = new TextField();
 // blank field of 20 columns
 tf2 = new TextField("", 20);
 // predefined text displayed
 tf3 = new TextField("Hello!");
 // predefined text in 30 columns
 tf4 = new TextField("Hello", 30);
 
</blockquote>

Every time the user types a key in the text field, one or more key events are sent to the text field. A KeyEvent may be one of three types: keyPressed, keyReleased, or keyTyped. The properties of a key event indicate which of these types it is, as well as additional information about the event, such as what modifiers are applied to the key event and the time at which the event occurred.

The key event is passed to every KeyListener or KeyAdapter object which registered to receive such events using the component's addKeyListener method. (KeyAdapter objects implement the KeyListener interface.)

It is also possible to fire an ActionEvent. If action events are enabled for the text field, they may be fired by pressing the Return key.

The TextField class's processEvent method examines the action event and passes it along to processActionEvent. The latter method redirects the event to any ActionListener objects that have registered to receive action events generated by this text field.

Version:
1.76, 01/23/03
Author:
Sami Shaio
See also:
java.awt.event.KeyEvent

java.awt.event.KeyAdapter

java.awt.event.KeyListener

java.awt.event.ActionEvent

java.awt.Component::addKeyListener

java.awt.TextField::processEvent

java.awt.TextField::processActionEvent

java.awt.TextField::addActionListener

Since:
JDK1.0

Public Member Functions

 TextField (const String &text=nilString, jint columns=0)
 Constructs a new text field initialized with the specified text to be displayed, and wide enough to hold the specified number of columns.
virtual jchar getEchoChar () const
 Gets the character that is to be used for echoing.
virtual void setEchoChar (jchar c)
 Sets the echo character for this text field.
virtual void setText (const String &t)
 Sets the text that is presented by this text component to be the specified text.
virtual jboolean echoCharIsSet () const
 Indicates whether or not this text field has a character set for echoing.
virtual jint getColumns () const
 Gets the number of columns in this text field.
virtual void setColumns (jint columns)
 Sets the number of columns in this text field.
virtual Dimension getPreferredSize (jint columns=0) const
 Gets the preferred size of this text field with the specified number of columns.
virtual Dimension getMinimumSize (jint columns=0) const
 Gets the minumum dimensions for a text field with the specified number of columns.

Protected Attributes

 REGISTER_MEMBERS

Constructor & Destructor Documentation

java::awt::TextField::TextField ( const String text = nilString,
jint  columns = 0 
)

Constructs a new text field initialized with the specified text to be displayed, and wide enough to hold the specified number of columns.

A column is an approximate average character width that is platform-dependent.

Parameters:
text the text to be displayed. If text is null, the empty string "" will be displayed.
columns the number of columns. If columns is less than 0, columns is set to 0.
Exceptions:
HeadlessException if GraphicsEnvironment.isHeadless() returns true.
See also:
java.awt.GraphicsEnvironment::isHeadless


Member Function Documentation

virtual jchar java::awt::TextField::getEchoChar (  )  const [virtual]

Gets the character that is to be used for echoing.

An echo character is useful for text fields where user input should not be echoed to the screen, as in the case of a text field for entering a password. If echoChar = 0, user input is echoed to the screen unchanged.

Returns:
the echo character for this text field.
See also:
java.awt.TextField::echoCharIsSet

java.awt.TextField::setEchoChar

virtual void java::awt::TextField::setEchoChar ( jchar  c  )  [virtual]

Sets the echo character for this text field.

An echo character is useful for text fields where user input should not be echoed to the screen, as in the case of a text field for entering a password. Setting echoChar = 0 allows user input to be echoed to the screen again.

Parameters:
c the echo character for this text field.
See also:
java.awt.TextField::echoCharIsSet

java.awt.TextField::getEchoChar

Since:
JDK1.1

virtual void java::awt::TextField::setText ( const String t  )  [virtual]

Sets the text that is presented by this text component to be the specified text.

Parameters:
t the new text.
See also:
java.awt.TextComponent::getText

Reimplemented from java::awt::TextComponent.

virtual jboolean java::awt::TextField::echoCharIsSet (  )  const [virtual]

Indicates whether or not this text field has a character set for echoing.

An echo character is useful for text fields where user input should not be echoed to the screen, as in the case of a text field for entering a password.

Returns:
true if this text field has a character set for echoing; false otherwise.
See also:
java.awt.TextField::setEchoChar

java.awt.TextField::getEchoChar

virtual jint java::awt::TextField::getColumns (  )  const [virtual]

Gets the number of columns in this text field.

A column is an approximate average character width that is platform-dependent.

Returns:
the number of columns.
See also:
java.awt.TextField::setColumns
Since:
JDK1.1

virtual void java::awt::TextField::setColumns ( jint  columns  )  [virtual]

Sets the number of columns in this text field.

A column is an approximate average character width that is platform-dependent.

Parameters:
columns the number of columns.
See also:
java.awt.TextField::getColumns
Exceptions:
IllegalArgumentException if the value supplied for columns is less than 0.
Since:
JDK1.1

virtual Dimension java::awt::TextField::getPreferredSize ( jint  columns = 0  )  const [virtual]

Gets the preferred size of this text field with the specified number of columns.

Parameters:
columns the number of columns in this text field.
Returns:
the preferred dimensions for displaying this text field.
Since:
JDK1.1

virtual Dimension java::awt::TextField::getMinimumSize ( jint  columns = 0  )  const [virtual]

Gets the minumum dimensions for a text field with the specified number of columns.

Parameters:
columns the number of columns in this text field.
Since:
JDK1.1


Member Data Documentation

java::awt::TextField::REGISTER_MEMBERS [protected]

Reimplemented from java::awt::TextComponent.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:12 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3