Class TextBoxBase
Abstract base class for all text entry widgets.
Nested Classes
Fields
ALIGN_CENTER | Center the text. |
ALIGN_JUSTIFY | Justify the text. |
ALIGN_LEFT | Align the text to the left edge. |
ALIGN_RIGHT | Align the text to the right. |
Constructors
Methods
Field Detail
ALIGN_CENTER
public static final TextBoxBase.TextAlignConstant ALIGN_CENTER
Center the text.
ALIGN_JUSTIFY
public static final TextBoxBase.TextAlignConstant ALIGN_JUSTIFY
Justify the text.
ALIGN_LEFT
public static final TextBoxBase.TextAlignConstant ALIGN_LEFT
Align the text to the left edge.
ALIGN_RIGHT
public static final TextBoxBase.TextAlignConstant ALIGN_RIGHT
Align the text to the right.
Constructor Detail
TextBoxBase
protected
TextBoxBase(
Element elem)
Creates a text box that wraps the given browser element handle. This is
only used by subclasses.
Parameters
- elem
- the browser element to wrap
Method Detail
addChangeListener
Adds a listener interface to receive change events.
Parameters
- listener
- the listener interface to add
addClickListener
Parameters
- listener
-
addKeyboardListener
Parameters
- listener
-
cancelKey
public void cancelKey()
If a keyboard event is currently being handled on this text box, calling
this method will suppress it. This allows listeners to easily filter
keyboard input.
getCursorPos
public int getCursorPos()
Gets the current position of the cursor (this also serves as the beginning
of the text selection).
Return Value
the cursor's position
getImpl
protected TextBoxImpl getImpl()
getName
Gets the widget's name.
Return Value
the widget's name
getSelectedText
public
String getSelectedText()
Gets the text currently selected within this text box.
Return Value
the selected text, or an empty string if none is selected
getSelectionLength
public int getSelectionLength()
Gets the length of the current text selection.
Return Value
the text selection length
getText
Gets this object's text.
Return Value
the object's text
isReadOnly
public boolean isReadOnly()
Determines whether or not the widget is read-only.
Return Value
true
if the widget is currently read-only,
false
if the widget is currently editable
onBrowserEvent
public void
onBrowserEvent(
Event event)
Parameters
- event
-
removeChangeListener
Removes a previously added listener interface.
Parameters
- listener
- the listener interface to remove
removeClickListener
Parameters
- listener
-
removeKeyboardListener
Parameters
- listener
-
selectAll
public void selectAll()
Selects all of the text in the box.
setCursorPos
public void setCursorPos(int pos)
Sets the cursor position.
Parameters
- pos
- the new cursor position
setKey
public void setKey(char key)
If a keyboard event is currently being handled by the text box, this method
replaces the unicode character or key code associated with it. This allows
listeners to easily filter keyboard input.
Parameters
- key
- the new key value
setName
public void
setName(
String name)
Sets the widget's name.
Parameters
- name
- the widget's new name
setReadOnly
public void setReadOnly(boolean readOnly)
Turns read-only mode on or off.
Parameters
- readOnly
- if
true
, the widget becomes read-only; if
false
the widget becomes editable
setSelectionRange
public void setSelectionRange(int pos, int length)
Sets the range of text to be selected.
Parameters
- pos
- the position of the first character to be selected
- length
- the number of characters to be selected
setText
public void
setText(
String text)
Sets this object's text.
Parameters
- text
- the object's new text
setTextAlignment
Sets the alignment of the text in the text box.
Parameters
- align
- the text alignment (as specified by ALIGN_CENTER,
ALIGN_JUSTIFY, ALIGN_LEFT, and
ALIGN_RIGHT)