java::awt::TextComponent Class Reference

Inheritance diagram for java::awt::TextComponent:

Inheritance graph
java::awt::TextAreajava::awt::TextFieldjava::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::TextComponent:

Collaboration graph
java::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

The TextComponent class is the superclass of any component that allows the editing of some text.

A text component embodies a string of text. The TextComponent class defines a set of methods that determine whether or not this text is editable. If the component is editable, it defines another set of methods that supports a text insertion caret.

In addition, the class defines methods that are used to maintain a current selection from the text. The text selection, a substring of the component's text, is the target of editing operations. It is also referred to as the selected text.

Version:
1.74, 01/23/03
Author:
Sami Shaio

Arthur van Hoff

Since:
JDK1.0

Public Member Functions

virtual String getText () const
 Returns the text that is presented by this text component.
virtual void setText (const String &text)
 Sets the text that is presented by this text component to be the specified text.
virtual String getSelectedText () const
 Returns the selected text from the text that is presented by this text component.
virtual jboolean isEditable () const
 Indicates whether or not this text component is editable.
virtual void setEditable (jboolean b)
 Sets the flag that determines whether or not this text component is editable.
virtual jint getSelectionStart () const
 Gets the start position of the selected text in this text component.
virtual void setSelectionStart (jint selectionStart=0)
 Sets the selection start for this text component to the specified position.
virtual jint getSelectionEnd () const
 Gets the end position of the selected text in this text component.
virtual void setSelectionEnd (jint selectionEnd=-1)
 Sets the selection end for this text component to the specified position.
virtual void select (jint selectionStart=0, jint selectionEnd=-1)
 Selects the text between the specified start and end positions.
virtual void selectAll ()
 Selects all the text in this text component.
virtual void setCaretPosition (jint position)
 Sets the position of the text insertion caret for this text component.
virtual jint getCaretPosition () const
 Gets the position of the text insertion caret for this text component.
virtual String toString () const
 Returns a string representation of this component and its values.

Member Function Documentation

virtual String java::awt::TextComponent::getText (  )  const [virtual]

Returns the text that is presented by this text component.

See also:
java.awt.TextComponent::setText

virtual void java::awt::TextComponent::setText ( const String text  )  [virtual]

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

Parameters:
t the new text; if this parameter is null then the text is set to the empty string ""
See also:
java.awt.TextComponent::getText

Reimplemented in java::awt::TextField.

virtual String java::awt::TextComponent::getSelectedText (  )  const [virtual]

Returns the selected text from the text that is presented by this text component.

Returns:
the selected text of this text component
See also:
java.awt.TextComponent::select

virtual jboolean java::awt::TextComponent::isEditable (  )  const [virtual]

Indicates whether or not this text component is editable.

Returns:
true if this text component is editable; false otherwise.
See also:
java.awt.TextComponent::setEditable
Since:
JDK1.0

virtual void java::awt::TextComponent::setEditable ( jboolean  b  )  [virtual]

Sets the flag that determines whether or not this text component is editable.

If the flag is set to true, this text component becomes user editable. If the flag is set to false, the user cannot change the text of this text component. By default, non-editable text components have a background color of SystemColor.control. This default can be overridden by calling setBackground.

Parameters:
b a flag indicating whether this text component is user editable.
See also:
java.awt.TextComponent::isEditable
Since:
JDK1.0

virtual jint java::awt::TextComponent::getSelectionStart (  )  const [virtual]

Gets the start position of the selected text in this text component.

Returns:
the start position of the selected text
See also:
java.awt.TextComponent::setSelectionStart

java.awt.TextComponent::getSelectionEnd

virtual void java::awt::TextComponent::setSelectionStart ( jint  selectionStart = 0  )  [virtual]

Sets the selection start for this text component to the specified position.

The new start point is constrained to be at or before the current selection end. It also cannot be set to less than zero, the beginning of the component's text. If the caller supplies a value for selectionStart that is out of bounds, the method enforces these constraints silently, and without failure.

Parameters:
selectionStart the start position of the selected text
See also:
java.awt.TextComponent::getSelectionStart

java.awt.TextComponent::setSelectionEnd

Since:
JDK1.1

virtual jint java::awt::TextComponent::getSelectionEnd (  )  const [virtual]

Gets the end position of the selected text in this text component.

Returns:
the end position of the selected text
See also:
java.awt.TextComponent::setSelectionEnd

java.awt.TextComponent::getSelectionStart

virtual void java::awt::TextComponent::setSelectionEnd ( jint  selectionEnd = -1  )  [virtual]

Sets the selection end for this text component to the specified position.

The new end point is constrained to be at or after the current selection start. It also cannot be set beyond the end of the component's text. If the caller supplies a value for selectionEnd that is out of bounds, the method enforces these constraints silently, and without failure.

Parameters:
selectionEnd the end position of the selected text
See also:
java.awt.TextComponent::getSelectionEnd

java.awt.TextComponent::setSelectionStart

Since:
JDK1.1

virtual void java::awt::TextComponent::select ( jint  selectionStart = 0,
jint  selectionEnd = -1 
) [virtual]

Selects the text between the specified start and end positions.

This method sets the start and end positions of the selected text, enforcing the restriction that the start position must be greater than or equal to zero. The end position must be greater than or equal to the start position, and less than or equal to the length of the text component's text. The character positions are indexed starting with zero. The length of the selection is endPosition - startPosition, so the character at endPosition is not selected. If the start and end positions of the selected text are equal, all text is deselected.

If the caller supplies values that are inconsistent or out of bounds, the method enforces these constraints silently, and without failure. Specifically, if the start position or end position is greater than the length of the text, it is reset to equal the text length. If the start position is less than zero, it is reset to zero, and if the end position is less than the start position, it is reset to the start position.

Parameters:
selectionStart the zero-based index of the first character to be selected
selectionEnd the zero-based end position of the text to be selected; the character at selectionEnd is not selected
See also:
java.awt.TextComponent::setSelectionStart

java.awt.TextComponent::setSelectionEnd

java.awt.TextComponent::selectAll

virtual void java::awt::TextComponent::selectAll (  )  [virtual]

Selects all the text in this text component.

See also:
java.awt.TextComponent::select

virtual void java::awt::TextComponent::setCaretPosition ( jint  position  )  [virtual]

Sets the position of the text insertion caret for this text component.

The caret position is constrained to be at or before the current selection end. If the caller supplies a value for position that is greater than the end of the component's text, the caret position is set to the end of the component's text. This happens silently and without failure. The caret position also cannot be set to less than zero, the beginning of the component's text. If the caller supplies a value for position that is less than zero, an IllegalArgumentException is thrown.

Parameters:
position the position of the text insertion caret
Exceptions:
IllegalArgumentException if the value supplied for position is less than zero
Since:
JDK1.1

virtual jint java::awt::TextComponent::getCaretPosition (  )  const [virtual]

Gets the position of the text insertion caret for this text component.

Returns:
the position of the text insertion caret
Since:
JDK1.1

virtual String java::awt::TextComponent::toString (  )  const [virtual]

Returns a string representation of this component and its values.

Returns:
a string representation of this component
Since:
JDK1.0

Reimplemented from java::awt::Component.


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