当前页面: 
在线文档首页 > 
JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
Class java.awt.TextComponent - JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
All Packages  Class Hierarchy  This Package  Previous  Next  Index
  Class java.awt.TextComponent
java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.TextComponent
  -  public class TextComponent
  -  extends Component
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.
   
  -   textListener textListener
-  
   
  -   addTextListener(TextListener) addTextListener(TextListener)
-   Adds the specified text event listener to recieve text events 
 from this textcomponent.
  
-   getCaretPosition() getCaretPosition()
-   Gets the position of the text insertion caret for 
 this text component.
  
-   getSelectedText() getSelectedText()
-   Gets the selected text from the text that is
 presented by this text component.
  
-   getSelectionEnd() getSelectionEnd()
-   Gets the end position of the selected text in 
 this text component.
  
-   getSelectionStart() getSelectionStart()
-   Gets the start position of the selected text in 
 this text component.
  
-   getText() getText()
-   Gets the text that is presented by this text component.
  
-   isEditable() isEditable()
-   Indicates whether or not this text component is editable.
  
-   paramString() paramString()
-   Returns the parameter string representing the state of this text 
 component.
  
-   processEvent(AWTEvent) processEvent(AWTEvent)
-   Processes events on this textcomponent.
  
-   processTextEvent(TextEvent) processTextEvent(TextEvent)
-  
 Processes text events occurring on this text component by
 dispatching them to any registered TextListener objects.
  
-   removeNotify() removeNotify()
-   Removes the TextComponent's peer.
  
-   removeTextListener(TextListener) removeTextListener(TextListener)
-   Removes the specified text event listener so that it no longer
 receives text events from this textcomponent
  
-   select(int, int) select(int, int)
-   Selects the text between the specified start and end positions.
  
-   selectAll() selectAll()
-   Selects all the text in this text component.
  
-   setCaretPosition(int) setCaretPosition(int)
-   Sets the position of the text insertion caret for 
 this text component.
  
-   setEditable(boolean) setEditable(boolean)
-   Sets the flag that determines whether or not this
 text component is editable.
  
-   setSelectionEnd(int) setSelectionEnd(int)
-   Sets the selection end for this text component to  
 the specified position.
  
-   setSelectionStart(int) setSelectionStart(int)
-   Sets the selection start for this text component to  
 the specified position.
  
-   setText(String) setText(String)
-   Sets the text that is presented by this 
 text component to be the specified text.
   
 textListener
textListener
 protected transient TextListener textListener
   
 removeNotify
removeNotify
 public void removeNotify()
  -  Removes the TextComponent's peer.  The peer allows us to modify
 the appearance of the TextComponent without changing its
 functionality.
   
- 
    -  Overrides:
    
-  removeNotify in class Component
  
 
 setText
setText
 public synchronized void setText(String t)
  -  Sets the text that is presented by this 
 text component to be the specified text.
   
- 
    -  Parameters:
    
-  t - the new text.
    
-  See Also:
    
-  getText
  
 
 getText
getText
 public synchronized String getText()
  -  Gets the text that is presented by this text component.
   
- 
    -  See Also:
    
-  setText
  
 
 getSelectedText
getSelectedText
 public synchronized String getSelectedText()
  -  Gets the selected text from the text that is
 presented by this text component.
   
- 
    -  Returns:
    
-  the selected text of this text component.
    
-  See Also:
    
-  select
  
 
 isEditable
isEditable
 public boolean isEditable()
  -  Indicates whether or not this text component is editable.
   
- 
    -  Returns:
    
-  trueif this text component is
                  editable;falseotherwise.
-  See Also:
    
-  setEditable
  
 
 setEditable
setEditable
 public synchronized void setEditable(boolean b)
  -  Sets the flag that determines whether or not this
 text component is editable.
 
 If the flag is set to true, this text component 
 becomes user editable. If the flag is set tofalse, 
 the user cannot change the text of this text component.
 
   
- 
    -  Parameters:
    
-  t - a flag indicating whether this text component
                      should be user editable.
    
-  See Also:
    
-  isEditable
  
 
 getSelectionStart
getSelectionStart
 public synchronized int getSelectionStart()
  -  Gets the start position of the selected text in 
 this text component.
   
- 
    -  Returns:
    
-  the start position of the selected text.
    
-  See Also:
    
-  setSelectionStart, getSelectionEnd
  
 
 setSelectionStart
setSelectionStart
 public synchronized void setSelectionStart(int selectionStart)
  -  Sets the selection start for this text component to  
 the specified position. The new start point is constrained 
 to be at or before the current selection end. It also
 cannot be set to less than zero, the beginning of the 
 component's text.
 If the caller supplies a value for selectionStartthat is out of bounds, the method enforces these constraints
 silently, and without failure.
   
- 
    -  Parameters:
    
-  selectionStart - the start position of the
                        selected text.
    
-  See Also:
    
-  getSelectionStart, setSelectionEnd
  
 
 getSelectionEnd
getSelectionEnd
 public synchronized int getSelectionEnd()
  -  Gets the end position of the selected text in 
 this text component.
   
- 
    -  Returns:
    
-  the end position of the selected text.
    
-  See Also:
    
-  setSelectionEnd, getSelectionStart
  
 
 setSelectionEnd
setSelectionEnd
 public synchronized void setSelectionEnd(int selectionEnd)
  -  Sets the selection end for this text component to  
 the specified position. The new end point is constrained 
 to be at or after the current selection start. It also
 cannot be set beyond the end of the component's text.
 If the caller supplies a value for selectionEndthat is out of bounds, the method enforces these constraints
 silently, and without failure.
   
- 
    -  Parameters:
    
-  selectionEnd - the end position of the
                        selected text.
    
-  See Also:
    
-  getSelectionEnd, setSelectionStart
  
 
 select
select
 public synchronized void select(int selectionStart,
                                 int selectionEnd)
  -  Selects the text between the specified start and end positions.
 
 This method sets the start and end positions of the 
 selected text, enforcing the restriction that the end 
 position must be greater than or equal to the start position.
 The start position must be greater than zero, and the 
 end position must be less that or equal to the length
 of the text component's text. If the caller supplies values
 that are inconsistent or out of bounds, the method enforces 
 these constraints silently, and without failure.
 
   
- 
    -  Parameters:
    
-  selectionStart - the start position of the
                             text to select.
    -  selectionEnd - the end position of the
                             text to select.
    
-  See Also:
    
-  setSelectionStart, setSelectionEnd, selectAll
  
 
 selectAll
selectAll
 public synchronized void selectAll()
  -  Selects all the text in this text component.
   
- 
    -  See Also:
    
-  TextComponent@select
  
 
 setCaretPosition
setCaretPosition
 public synchronized void setCaretPosition(int position)
  -  Sets the position of the text insertion caret for 
 this text component.
   
- 
    -  Parameters:
    
-  position - the position of the text insertion caret.
    
-  Throws: IllegalArgumentException
    
-  if the value supplied
                   for positionis less than zero.
 
 getCaretPosition
getCaretPosition
 public synchronized int getCaretPosition()
  -  Gets the position of the text insertion caret for 
 this text component.
   
- 
    -  Returns:
    
-  the position of the text insertion caret.
  
 
 addTextListener
addTextListener
 public synchronized void addTextListener(TextListener l)
  -  Adds the specified text event listener to recieve text events 
 from this textcomponent.
   
- 
    -  Parameters:
    
-  l - the text event listener
  
 
 removeTextListener
removeTextListener
 public synchronized void removeTextListener(TextListener l)
  -  Removes the specified text event listener so that it no longer
 receives text events from this textcomponent
 
 processEvent
processEvent
 protected void processEvent(AWTEvent e)
  -  Processes events on this textcomponent. If the event is a
 TextEvent, it invokes the processTextEvent method,
 else it invokes its superclass's processEvent.
   
- 
    -  Parameters:
    
-  e - the event
    
-  Overrides:
    
-  processEvent in class Component
  
 
 processTextEvent
processTextEvent
 protected void processTextEvent(TextEvent e)
  -  Processes text events occurring on this text component by
 dispatching them to any registered TextListener objects.
 NOTE: This method will not be called unless text events
 are enabled for this component; this happens when one of the
 following occurs:
 a) A TextListener object is registered via addTextListener()
 b) Text events are enabled via enableEvents()
   
- 
    -  Parameters:
    
-  e - the text event
    
-  See Also:
    
-  enableEvents
  
 
 paramString
paramString
 protected String paramString()
  -  Returns the parameter string representing the state of this text 
 component. This string is useful for debugging.
   
- 
    -  Returns:
    
-  the parameter string of this text component.
    
-  Overrides:
    
-  paramString in class Component
  
 
All Packages  Class Hierarchy  This Package  Previous  Next  Index
Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems,  Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A.  All Rights Reserved.