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.

removeTextListener(TextListener l)
Removes the specified text event listener so that it no longer
receives text events from this text component
If l is null, no exception is
thrown and no action is performed.

void

select(int selectionStart,
int selectionEnd)
Selects the text between the specified start and end positions.

textListener

enableInputMethods

Enables or disables input method support for this component. If input
method support is enabled and the component also processes key events,
incoming events are offered to
the current input method and will only be processed by the component or
dispatched to its listeners if the input method does not consume them.
By default, input method support is enabled.

isEditable

setEditable

public void setEditable(boolean b)

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.

getSelectionStart

setSelectionStart

public void setSelectionStart(int selectionStart)

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.

getSelectionEnd

setSelectionEnd

public void setSelectionEnd(int selectionEnd)

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.

select

public void select(int selectionStart,
int selectionEnd)

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

selectAll

setCaretPosition

public void setCaretPosition(int position)

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.

paramString

Returns a string representing the state of this
TextComponent. This
method is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null.

getAccessibleContext

Gets the AccessibleContext associated with this TextComponent.
For text components, the AccessibleContext takes the form of an
AccessibleAWTTextComponent.
A new AccessibleAWTTextComponent instance is created if necessary.