java.awt
public class TextComponent extends Component implements Serializable, Accessible
| Nested Class Summary | |
|---|---|
| protected class | TextComponent.AccessibleAWTTextComponent |
| Field Summary | |
|---|---|
| protected TextListener | textListener
A list of listeners that will receive events from this object. |
| Method Summary | |
|---|---|
| void | addTextListener(TextListener listener)
Adds a new listener to the list of text listeners for this
component.
|
| AccessibleContext | getAccessibleContext()
Gets the AccessibleContext associated with this TextComponent.
|
| int | getCaretPosition()
Returns the current caret position in the text.
|
| <T extends EventListener> T[] | getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListeners
upon this TextComponent. |
| String | getSelectedText()
Returns a string that contains the text that is currently selected.
|
| int | getSelectionEnd()
Returns the ending position of the selected text region.
|
| int | getSelectionStart()
Returns the starting position of the selected text region.
|
| String | getText()
Returns the text in this component
|
| TextListener[] | getTextListeners()
Returns all text listeners registered to this object. |
| boolean | isEditable()
Tests whether or not this component's text can be edited.
|
| protected String | paramString()
Returns a debugging string.
|
| protected void | processEvent(AWTEvent event)
Processes the specified event for this component. |
| protected void | processTextEvent(TextEvent event)
Processes the specified text event by dispatching it to any listeners
that are registered. |
| void | removeNotify()
Notifies the component that it should destroy its native peer. |
| void | removeTextListener(TextListener listener)
Removes the specified listener from the list of listeners
for this component.
|
| void | select(int selectionStart, int selectionEnd)
This method sets the selected text range to the text between the
specified start and end positions. |
| void | selectAll()
Selects all of the text in the component. |
| void | setCaretPosition(int caretPosition)
Sets the caret position to the specified value.
|
| void | setEditable(boolean editable)
Sets whether or not this component's text can be edited.
|
| void | setSelectionEnd(int selectionEnd)
Sets the ending position of the selected region to the
specified value. |
| void | setSelectionStart(int selectionStart)
Sets the starting position of the selected region to the
specified value. |
| void | setText(String text)
Sets the text in this component to the specified string.
|
Parameters: listener The listener to be added.
TextComponent.
The context is created, if necessary.
Returns: the associated context
Returns: The caret position in the text.
TextComponent. FooListeners are registered using
the addFooListener method.
Throws: ClassCastException If listenerType doesn't specify a class or interface that implements java.util.EventListener.
Returns: The currently selected text region.
Returns: The ending position of the selected text region.
Returns: The starting position of the selected text region.
Returns: The text in this component.
Returns: true if the text can be edited, false
otherwise.
Returns: A debugging string.
processTextEvent() method.
All other events are passed to the superclass method.
Parameters: event The event to process.
enableEvents().
Parameters: event The text event to process.
Parameters: listener The listener to remove.
Parameters: selectionStart The new start position for the selected text. selectionEnd The new end position for the selected text.
Parameters: caretPosition The new caret position.
Throws: IllegalArgumentException If the value supplied for position is less than zero.
Since: 1.1
Parameters: editable true to enable editing of the text,
false to disable it.
Parameters: selectionEnd The new start position for selected text.
Parameters: selectionStart The new start position for selected text.
Parameters: text The new text for this component.