buoy.widget
Class TextWidget

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.TextWidget
Direct Known Subclasses:
BTextArea, BTextField

public abstract class TextWidget
extends Widget

A TextWidget is a Widget that allows the user to view and edit text. This is an abstract class. Subclasses implement specific types of text editing Widgets

Author:
Peter Eastman

Method Summary
 int getCaretPosition()
          Get the current position of the caret.
 javax.swing.text.JTextComponent getComponent()
          Get the java.awt.Component corresponding to this Widget.
 int getLength()
          Get the number of characters in the text contained in the Widget.
 java.lang.String getSelectedText()
          Get the selected text.
 int getSelectionEnd()
          Get the end of the selected range.
 int getSelectionStart()
          Get the start of the selected range.
 java.lang.String getText()
          Get the text contained in the Widget.
 boolean isEditable()
          Determine whether the user can edit the text contained in this text field.
 void setCaretPosition(int pos)
          Set the current position of the caret.
 void setEditable(boolean editable)
          Set whether the user can edit the text contained in this text field.
 void setSelectionEnd(int pos)
          Set the end of the selected range.
 void setSelectionStart(int pos)
          Set the start of the selected range.
 void setText(java.lang.String text)
          Set the text contained in the Widget.
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getComponent

public javax.swing.text.JTextComponent getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class Widget

getText

public java.lang.String getText()
Get the text contained in the Widget.


setText

public void setText(java.lang.String text)
Set the text contained in the Widget.

This method can be safely called from any thread, not just the event dispatch thread.


getLength

public int getLength()
Get the number of characters in the text contained in the Widget.


getCaretPosition

public int getCaretPosition()
Get the current position of the caret.


setCaretPosition

public void setCaretPosition(int pos)
Set the current position of the caret.


getSelectionStart

public int getSelectionStart()
Get the start of the selected range. This is the index of the first selected character.


setSelectionStart

public void setSelectionStart(int pos)
Set the start of the selected range. This is the index of the first selected character.


getSelectionEnd

public int getSelectionEnd()
Get the end of the selected range. This is the index of the first character after the end of the selection.


setSelectionEnd

public void setSelectionEnd(int pos)
Set the end of the selected range. This is the index of the first character after the end of the selection.


getSelectedText

public java.lang.String getSelectedText()
Get the selected text. This returns null if no text is currently selected.


isEditable

public boolean isEditable()
Determine whether the user can edit the text contained in this text field.


setEditable

public void setEditable(boolean editable)
Set whether the user can edit the text contained in this text field.



Written by Peter Eastman.