buoy.widget

Class TextWidget

Known Direct 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.
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.
String
getSelectedText()
Get the selected text.
int
getSelectionEnd()
Get the end of the selected range.
int
getSelectionStart()
Get the start of the selected range.
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(String text)
Set the text contained in the Widget.

Methods inherited from class buoy.widget.Widget

addEventLink, dispatchEvent, getBackground, getBounds, getComponent, 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, addEventLink, dispatchEvent, removeEventLink

Method Details

getCaretPosition

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

getComponent

public JTextComponent getComponent()
Get the java.awt.Component corresponding to this Widget.
Overrides:
getComponent in interface Widget

getLength

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

getSelectedText

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

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.

getSelectionStart

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

getText

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

isEditable

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

setCaretPosition

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

setEditable

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

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.

setSelectionStart

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

setText

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

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


Written by Peter Eastman.