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.
| Modifier and Type | Class and Description |
|---|---|
| protected class | TextComponent.
This class implements accessibility support for the
|
| Modifier and Type | Field and Description |
|---|---|
| pack-priv boolean | |
| private boolean | |
| pack-priv boolean | editable
A boolean indicating whether or not this
|
| pack-priv int | selectionEnd
The selection refers to the selected text, and the
|
| pack-priv int | selectionStart
The selection refers to the selected text, and the
|
| private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
| pack-priv String | text
The value of the text. |
| private int | textComponentSerializedDataVersion
The textComponent SerializedDataVersion. |
| protected transient TextListener | textListener
A list of listeners that will receive events from this object. |
| Access | Constructor and Description |
|---|---|
| pack-priv | TextComponent(String
the text to be displayed; if
text)text is null, the empty
string "" will be displayedConstructs a new text component initialized with the specified text. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addNotify()
Overrides java. Makes this Component displayable by connecting it to a native screen resource. |
| public synchronized void | addTextListener(TextListener
the text event listener l)Adds the specified text event listener to receive text events from this text component. |
| pack-priv boolean | |
| public void | enableInputMethods(boolean
true to enable, false to disable enable)Overrides java. Enables or disables input method support for this text component. |
| private void | |
| pack-priv boolean | |
| public AccessibleContext | Returns: an AccessibleAWTTextComponent that serves as the AccessibleContext of this TextComponentOverrides java. Implements javax. Gets the AccessibleContext associated with this TextComponent. |
| public Color | Returns: This text component's background color. If this text component does not have a background color, the background color of its parent is returned.Overrides java. Gets the background color of this text component. |
| public synchronized int | Returns: the position of the text insertion caretReturns the position of the text insertion caret. |
| public InputMethodRequests | getInputMethodRequests()
Overrides java. Gets the input method request handler which supports requests from input methods for this component. |
| public <T extends EventListener> T[] | Returns: an array of all objects registered asFooListeners on this text component,
or an empty array if no such
listeners have been addedthe type of listeners requested; this parameter
should specify an interface that descends from
listenerType)java.util.EventListenerOverrides java. Returns an array of all the objects currently registered
as |
| public synchronized String | Returns: the selected text of this text componentReturns the selected text from the text that is presented by this text component. |
| public synchronized int | Returns: the end position of the selected textGets the end position of the selected text in this text component. |
| public synchronized int | Returns: the start position of the selected textGets the start position of the selected text in this text component. |
| public synchronized String | Returns: the value of thisTextComponentReturns the text that is presented by this text component. |
| public synchronized TextListener[] | Returns: all of this text component'sTextListeners
or an empty array if no text
listeners are currently registeredReturns an array of all the text listeners registered on this text component. |
| public boolean | Returns: true if this text component is
editable; false otherwise.Indicates whether or not this text component is editable. |
| protected String | Returns: the parameter string of this text componentOverrides java. Returns a string representing the state of this
|
| protected void | processEvent(AWTEvent
the event e)Overrides java. Processes events on this text component. |
| protected void | processTextEvent(TextEvent
the text event e)Processes text events occurring on this text component by
dispatching them to any registered |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to readHides java. Read the ObjectInputStream, and if it isn't null, add a listener to receive text events fired by the TextComponent. |
| public void | |
| public synchronized void | removeTextListener(TextListener
the text listener l)Removes the specified text event listener so that it no longer
receives text events from this text component
If |
| public synchronized void | select(int
the zero-based index of the first
character ( selectionStart, int char value) to be selectedthe zero-based end position of the
text to be selected; the character ( selectionEnd)char value) at
selectionEnd is not selectedSelects the text between the specified start and end positions. |
| public synchronized void | |
| public void | setBackground(Color
The color to become this text component's color.
If this parameter is null then this text component
will inherit the background color of its parent. c)Overrides java. Sets the background color of this text component. |
| public synchronized void | setCaretPosition(int
the position of the text insertion caret position)Sets the position of the text insertion caret. |
| public synchronized void | setEditable(boolean
a flag indicating whether this text component
is user editable. b)Sets the flag that determines whether or not this text component is editable. |
| public synchronized void | setSelectionEnd(int
the end position of the
selected text selectionEnd)Sets the selection end for this text component to the specified position. |
| public synchronized void | setSelectionStart(int
the start position of the
selected text selectionStart)Sets the selection start for this text component to the specified position. |
| public synchronized void | |
| private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to writeHides java. Writes default serializable fields to stream. |