java.awt
Class TextComponent

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.TextComponent
All Implemented Interfaces:
ImageObserver
Direct Known Subclasses:
TextArea, TextField

public class TextComponent
extends Component

common abstract base class for TextArea and TextField


Constructor Summary
TextComponent()
           
 
Method Summary
 void addTextListener(TextListener tl)
          Sets the textListener for this TextComponent.
 void dispatchEvent(AWTEvent event)
          Performs the action associated with the given KeyEvent
 int getCaretPosition()
          Returns the current caret position
 java.lang.String getSelectedText()
          returns the selected substring of the text content.
 int getSelectionEnd()
          returns the end position of the current selection.
 int getSelectionStart()
          returns the start position of the current selection.
 java.lang.String getText()
          Returns the String content of this text component
 boolean isEditable()
          Returns true if the Textfield is editable, false otherwise.
 boolean isFocusTraversable()
          Returns if the textfield can be reached by focus traversal.
 void removeTextListener(TextListener tl)
          Removes the given TextListener from this TextArea.
 void select(int start, int end)
          Selects the text at the given positon
 void selectAll()
          Selects the whole text content.
 void setCaretPosition(int cp)
          Sets the current cursor position
 void setEditable(boolean ed)
          Sets the text content to editable or not editable.
 void setSelectionEnd(int i)
          Sets the end position of the current selection.
 void setSelectionStart(int i)
          Sets the start position of the current selection.
 void setText(java.lang.String newText)
          Sets the text content to the given String
 
Methods inherited from class java.awt.Component
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, contains, enableEvents, findComponentAt, getBackground, getBounds, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getLocationOnScreen, getMaximumSize, getMinimumSize, getParent, getPreferredSize, getSize, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isValid, isVisible, paint, paintAll, processEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, repaint, repaint, requestFocus, setBackground, setBounds, setEnabled, setFont, setForeground, setLocation, setSize, setSize, setVisible, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextComponent

public TextComponent()
Method Detail

addTextListener

public void addTextListener(TextListener tl)
Sets the textListener for this TextComponent. The TextListener is notified when the text content changes. Caution: In contrast to the AWT, KAWT supports * only one TextListener!

getCaretPosition

public int getCaretPosition()
Returns the current caret position

dispatchEvent

public void dispatchEvent(AWTEvent event)
Performs the action associated with the given KeyEvent
Overrides:
dispatchEvent in class Component

getSelectedText

public java.lang.String getSelectedText()
returns the selected substring of the text content. If no text is selected, an empty String is returned.

getSelectionStart

public int getSelectionStart()
returns the start position of the current selection.

getSelectionEnd

public int getSelectionEnd()
returns the end position of the current selection.

getText

public java.lang.String getText()
Returns the String content of this text component

isEditable

public boolean isEditable()
Returns true if the Textfield is editable, false otherwise.

isFocusTraversable

public boolean isFocusTraversable()
Returns if the textfield can be reached by focus traversal. True if the Textfield is editable, false otherwise.
Overrides:
isFocusTraversable in class Component

removeTextListener

public void removeTextListener(TextListener tl)
Removes the given TextListener from this TextArea.

select

public void select(int start,
                   int end)
Selects the text at the given positon

selectAll

public void selectAll()
Selects the whole text content.

setEditable

public void setEditable(boolean ed)
Sets the text content to editable or not editable.

setCaretPosition

public void setCaretPosition(int cp)
Sets the current cursor position

setSelectionStart

public void setSelectionStart(int i)
Sets the start position of the current selection.

setSelectionEnd

public void setSelectionEnd(int i)
Sets the end position of the current selection.

setText

public void setText(java.lang.String newText)
Sets the text content to the given String