java.awt
Class TextComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.TextComponent
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
TextArea, TextField
public class TextComponent
extends Component
implements Accessible

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.

Since:
JDK1.0
See Also:
Serialized Form

 

Nested Class Summary

protected  class TextComponent.AccessibleAWTTextComponent
    This class implements accessibility support for the TextComponent class.
 
Nested classes inherited from class java.awt.Component
Component.BltBufferStrategy, Component.FlipBufferStrategy
 

 

Field Summary

protected  TextListener textListener
    
 
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 addNotify()
    Makes this Component displayable by connecting it to a native screen resource.
 void addTextListener(TextListener l)
    Adds the specified text event listener to receive text events from this text component.
 void enableInputMethods(boolean enable)
    Enables or disables input method support for this component.
 AccessibleContext getAccessibleContext()
    Gets the AccessibleContext associated with this TextComponent.
 Color getBackground()
    Gets the background color of this text component.
 int getCaretPosition()
    Gets the position of the text insertion caret for this text component.
 EventListener[] getListeners(Class listenerType)
    Returns an array of all the objects currently registered as FooListeners upon this TextComponent.
 String getSelectedText()
    Returns the selected text from the text that is presented by this text component.
 int getSelectionEnd()
    Gets the end position of the selected text in this text component.
 int getSelectionStart()
    Gets the start position of the selected text in this text component.
 String getText()
    Returns the text that is presented by this text component.
 TextListener[] getTextListeners()
    Returns an array of all the text listeners registered on this text component.
 boolean isEditable()
    Indicates whether or not this text component is editable.
protected  String paramString()
    Returns a string representing the state of this TextComponent.
protected  void processEvent(AWTEvent e)
    Processes events on this text component.
protected  void processTextEvent(TextEvent e)
    Processes text events occurring on this text component by dispatching them to any registered TextListener objects.
 void removeNotify()
    Removes the TextComponent's peer.
 void 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.
 void selectAll()
    Selects all the text in this text component.
 void setBackground(Color c)
    Sets the background color of this text component.
 void setCaretPosition(int position)
    Sets the position of the text insertion caret for this text component.
 void setEditable(boolean b)
    Sets the flag that determines whether or not this text component is editable.
 void setSelectionEnd(int selectionEnd)
    Sets the selection end for this text component to the specified position.
 void setSelectionStart(int selectionStart)
    Sets the selection start for this text component to the specified position.
 void setText(String t)
    Sets the text that is presented by this text component to be the specified text.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size,