java.awt
Class TextComponent
- Accessible, ImageObserver, MenuContainer, Serializable
This class provides common functionality for widgets than
contain text.
void | addTextListener(TextListener listener) - Adds a new listener to the list of text listeners for this
component.
|
| extends EventListener> T[] getListeners(Class listenerType) - Returns an array of all the objects currently registered as FooListeners
upon this
TextComponent .
|
AccessibleContext | getAccessibleContext() - Gets the AccessibleContext associated with this
TextComponent .
|
int | getCaretPosition() - Returns the current caret position in the text.
|
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.
|
action , add , addComponentListener , addFocusListener , addHierarchyBoundsListener , addHierarchyListener , addInputMethodListener , addKeyListener , addMouseListener , addMouseMotionListener , addMouseWheelListener , addNotify , addPropertyChangeListener , addPropertyChangeListener , applyComponentOrientation , areFocusTraversalKeysSet , bounds , checkImage , checkImage , coalesceEvents , contains , contains , createImage , createImage , createVolatileImage , createVolatileImage , deliverEvent , disable , disableEvents , dispatchEvent , doLayout , enable , enable , enableEvents , enableInputMethods , extends EventListener> T[] getListeners , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , firePropertyChange , getAccessibleContext , getAlignmentX , getAlignmentY , getBackground , 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 , getMousePosition , 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 , isFocusCycleRoot , isFocusOwner , isFocusTraversable , isFocusable , isFontSet , isForegroundSet , isLightweight , isMaximumSizeSet , isMinimumSizeSet , isOpaque , isPreferredSizeSet , 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 , paramString , postEvent , preferredSize , prepareImage , prepareImage , print , printAll , processComponentEvent , processEvent , processFocusEvent , processHierarchyBoundsEvent , processHierarchyEvent , processInputMethodEvent , processKeyEvent , processMouseEvent , processMouseMotionEvent , processMouseWheelEvent , remove , removeComponentListener , removeFocusListener , removeHierarchyBoundsListener , removeHierarchyListener , removeInputMethodListener , removeKeyListener , removeMouseListener , removeMouseMotionListener , removeMouseWheelListener , removeNotify , removePropertyChangeListener , removePropertyChangeListener , repaint , repaint , repaint , repaint , requestFocus , requestFocus , requestFocusInWindow , requestFocusInWindow , reshape , resize , resize , setBackground , setBounds , setBounds , setComponentOrientation , setCursor , setDropTarget , setEnabled , setFocusTraversalKeys , setFocusTraversalKeysEnabled , setFocusable , setFont , setForeground , setIgnoreRepaint , setLocale , setLocation , setLocation , setMaximumSize , setMinimumSize , setName , setPreferredSize , setSize , setSize , setVisible , show , show , size , toString , transferFocus , transferFocusBackward , transferFocusUpCycle , update , validate |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
addTextListener
public void addTextListener(TextListener listener)
Adds a new listener to the list of text listeners for this
component.
listener
- The listener to be added.
extends EventListener> T[] getListeners
public extends EventListener> T[] getListeners(Class listenerType)
Returns an array of all the objects currently registered as FooListeners
upon this TextComponent
. FooListeners are registered using
the addFooListener method.
- extends EventListener> T[] getListeners in interface Component
ClassCastException
- If listenerType doesn't specify a class or
interface that implements java.util.EventListener.
getCaretPosition
public int getCaretPosition()
Returns the current caret position in the text.
- The caret position in the text.
getSelectedText
public String getSelectedText()
Returns a string that contains the text that is currently selected.
- The currently selected text region.
getSelectionEnd
public int getSelectionEnd()
Returns the ending position of the selected text region.
If the text is not selected, then caret position is returned
- The ending position of the selected text region.
getSelectionStart
public int getSelectionStart()
Returns the starting position of the selected text region.
If the text is not selected then caret position is returned.
- The starting position of the selected text region.
getText
public String getText()
Returns the text in this component
- The text in this component.
isEditable
public boolean isEditable()
Tests whether or not this component's text can be edited.
true
if the text can be edited, false
otherwise.
processEvent
protected void processEvent(AWTEvent event)
Processes the specified event for this component. Text events are
processed by calling the processTextEvent()
method.
All other events are passed to the superclass method.
- processEvent in interface Component
event
- The event to process.
processTextEvent
protected void processTextEvent(TextEvent event)
Processes the specified text event by dispatching it to any listeners
that are registered. Note that this method will only be called
if text event's are enabled. This will be true if there are any
registered listeners, or if the event has been specifically
enabled using enableEvents()
.
event
- The text event to process.
removeTextListener
public void removeTextListener(TextListener listener)
Removes the specified listener from the list of listeners
for this component.
listener
- The listener to remove.
select
public void select(int selectionStart,
int selectionEnd)
This method sets the selected text range to the text between the
specified start and end positions. Illegal values for these
positions are silently fixed.
selectionStart
- The new start position for the selected text.selectionEnd
- The new end position for the selected text.
selectAll
public void selectAll()
Selects all of the text in the component.
setCaretPosition
public void setCaretPosition(int caretPosition)
Sets the caret position to the specified value.
caretPosition
- The new caret position.
setEditable
public void setEditable(boolean editable)
Sets whether or not this component's text can be edited.
editable
- true
to enable editing of the text,
false
to disable it.
setSelectionEnd
public void setSelectionEnd(int selectionEnd)
Sets the ending position of the selected region to the
specified value. If the specified value is out of range, then it
will be silently changed to the nearest legal value.
selectionEnd
- The new start position for selected text.
setSelectionStart
public void setSelectionStart(int selectionStart)
Sets the starting position of the selected region to the
specified value. If the specified value is out of range, then it
will be silently changed to the nearest legal value.
selectionStart
- The new start position for selected text.
setText
public void setText(String text)
Sets the text in this component to the specified string.
text
- The new text for this component.
TextComponent.java -- Widgets for entering text
Copyright (C) 1999, 2002, 2003, 2006, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.