|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.TextComponent
public class TextComponent
This class provides common functionality for widgets than contain text.
| Nested Class Summary | |
|---|---|
protected class |
TextComponent.AccessibleAWTTextComponent
|
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected TextListener |
textListener
A list of listeners that will receive events from this object. |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| 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. |
|
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected transient TextListener textListener
| Method Detail |
|---|
public String getText()
public void setText(String text)
text - The new text for this component.public String getSelectedText()
public int getSelectionStart()
public void setSelectionStart(int selectionStart)
selectionStart - The new start position for selected text.public int getSelectionEnd()
public void setSelectionEnd(int selectionEnd)
selectionEnd - The new start position for selected text.
public void select(int selectionStart,
int selectionEnd)
selectionStart - The new start position for the selected text.selectionEnd - The new end position for the selected text.public void selectAll()
public int getCaretPosition()
public void setCaretPosition(int caretPosition)
caretPosition - The new caret position.
IllegalArgumentException - If the value supplied for position
is less than zero.public boolean isEditable()
true if the text can be edited, false
otherwise.public void setEditable(boolean editable)
editable - true to enable editing of the text,
false to disable it.public void removeNotify()
removeNotify in class ComponentComponent.isDisplayable(),
Component.addNotify()public void addTextListener(TextListener listener)
listener - The listener to be added.public void removeTextListener(TextListener listener)
listener - The listener to remove.protected void processEvent(AWTEvent event)
processTextEvent() method.
All other events are passed to the superclass method.
processEvent in class Componentevent - The event to process.Component.processComponentEvent(ComponentEvent),
Component.processFocusEvent(FocusEvent),
Component.processKeyEvent(KeyEvent),
Component.processMouseEvent(MouseEvent),
Component.processMouseMotionEvent(MouseEvent),
Component.processInputMethodEvent(InputMethodEvent),
Component.processHierarchyEvent(HierarchyEvent),
Component.processMouseWheelEvent(MouseWheelEvent)protected void processTextEvent(TextEvent event)
enableEvents().
event - The text event to process.protected String paramString()
paramString in class Componentpublic <T extends EventListener> T[] getListeners(Class<T> listenerType)
TextComponent. FooListeners are registered using
the addFooListener method.
getListeners in class ComponentlistenerType - the class of listeners to filter (null
not permitted).
ClassCastException - If listenerType doesn't specify a class or
interface that implements java.util.EventListener.Component.getComponentListeners(),
Component.getFocusListeners(),
Component.getHierarchyListeners(),
Component.getHierarchyBoundsListeners(),
Component.getKeyListeners(),
Component.getMouseListeners(),
Component.getMouseMotionListeners(),
Component.getMouseWheelListeners(),
Component.getInputMethodListeners(),
Component.getPropertyChangeListeners()public TextListener[] getTextListeners()
public AccessibleContext getAccessibleContext()
TextComponent.
The context is created, if necessary.
getAccessibleContext in interface AccessiblegetAccessibleContext in class Component
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||