Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.user.client.ui
Class TextBoxBase

    java.lang.Object
      com.google.gwt.user.client.ui.UIObject
          com.google.gwt.user.client.ui.Widget
              com.google.gwt.user.client.ui.FocusWidget
                  com.google.gwt.user.client.ui.TextBoxBase

All Implemented Interfaces:
  EventListener, HasFocus, HasName, HasText, SourcesChangeEvents, SourcesClickEvents, SourcesFocusEvents, SourcesKeyboardEvents

Direct Known Subclasses:
  PasswordTextBox, TextArea, TextBox

    public class TextBoxBase

extends FocusWidget
implements SourcesKeyboardEvents, SourcesChangeEvents, SourcesClickEvents, HasText, HasName

Abstract base class for all text entry widgets.

Nested Class Summary
`static class` | `TextBoxBase.TextAlignConstant` Text alignment constant, used in `setTextAlignment(TextBoxBase.TextAlignConstant)`.

Field Summary
`static TextBoxBase.TextAlignConstant` | `ALIGN_CENTER` Center the text.
`static TextBoxBase.TextAlignConstant` | `ALIGN_JUSTIFY` Justify the text.
`static TextBoxBase.TextAlignConstant` | `ALIGN_LEFT` Align the text to the left edge.
`static TextBoxBase.TextAlignConstant` | `ALIGN_RIGHT` Align the text to the right.

Constructor Summary
`protected` | `TextBoxBase(Element elem)` Creates a text box that wraps the given browser element handle.

Method Summary
`void` | `addChangeListener(ChangeListener listener)` Adds a listener interface to receive change events.
`void` | `addClickListener(ClickListener listener)` Adds a listener interface to receive click events.
`void` | `addKeyboardListener(KeyboardListener listener)` Adds a listener interface to receive keyboard events.
`void` | `cancelKey()` If a keyboard event is currently being handled on this text box, calling this method will suppress it.
`int` | `getCursorPos()` Gets the current position of the cursor (this also serves as the beginning of the text selection).
`protected com.google.gwt.user.client.ui.impl.TextBoxImpl` | `getImpl()`
`java.lang.String` | `getName()` Gets the widget's name.
`java.lang.String` | `getSelectedText()` Gets the text currently selected within this text box.
`int` | `getSelectionLength()` Gets the length of the current text selection.
`java.lang.String` | `getText()` Gets this object's text.
`boolean` | `isReadOnly()` Determines whether or not the widget is read-only.
`void` | `onBrowserEvent(Event event)` Fired whenever a browser event is received.
`void` | `removeChangeListener(ChangeListener listener)` Removes a previously added listener interface.
`void` | `removeClickListener(ClickListener listener)` Removes a previously added listener interface.
`void` | `removeKeyboardListener(KeyboardListener listener)` Removes a previously added listener interface.
`void` | `selectAll()` Selects all of the text in the box.
`void` | `setCursorPos(int pos)` Sets the cursor position.
`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.
`void` | `setName(java.lang.String name)` Sets the widget's name.
`void` | `setReadOnly(boolean readOnly)` Turns read-only mode on or off.
`void` | `setSelectionRange(int pos, int length)` Sets the range of text to be selected.
`void` | `setText(java.lang.String text)` Sets this object's text.
`void` | `setTextAlignment(TextBoxBase.TextAlignConstant align)` Sets the alignment of the text in the text box.

Methods inherited from class com.google.gwt.user.client.ui.FocusWidget
`addFocusListener, getFocusImpl, getTabIndex, isEnabled, removeFocusListener, setAccessKey, setElement, setEnabled, setFocus, setTabIndex`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onDetach, onLoad, onUnload, removeFromParent`

Methods inherited from class com.google.gwt.user.client.ui.UIObject
`addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

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

    public void addChangeListener(ChangeListener listener)

  Description copied from interface: `SourcesChangeEvents`
  Adds a listener interface to receive change events.

  Specified by:
    `addChangeListener` in interface `SourcesChangeEvents`
  Parameters:
    `listener` - the listener interface to add

### addClickListener

    public void addClickListener(ClickListener listener)

  Description copied from interface: `SourcesClickEvents`
  Adds a listener interface to receive click events.

  Specified by:
    `addClickListener` in interface `SourcesClickEvents`
  Overrides:
    `addClickListener` in class `FocusWidget`
  Parameters:
    `listener` - the listener interface to add

### addKeyboardListener

    public void addKeyboardListener(KeyboardListener listener)

  Description copied from interface: `SourcesKeyboardEvents`
  Adds a listener interface to receive keyboard events.

  Specified by:
    `addKeyboardListener` in interface `SourcesKeyboardEvents`
  Overrides:
    `addKeyboardListener` in class `FocusWidget`
  Parameters:
    `listener` - the listener interface to add

### 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).

  Returns:
    the cursor's position

### getName

    public java.lang.String getName()

  Description copied from interface: `HasName`
  Gets the widget's name.

  Specified by:
    `getName` in interface `HasName`
  Returns:
    the widget's name

### getSelectedText

    public java.lang.String getSelectedText()

  Gets the text currently selected within this text box.

  Returns:
    the selected text, or an empty string if none is selected

### getSelectionLength

    public int getSelectionLength()

  Gets the length of the current text selection.

  Returns:
    the text selection length

### getText

    public java.lang.String getText()

  Description copied from interface: `HasText`
  Gets this object's text.

  Specified by:
    `getText` in interface `HasText`
  Returns:
    the object's text

### isReadOnly

    public boolean isReadOnly()

  Determines whether or not the widget is read-only.

  Returns:
    `true` if the widget is currently read-only, `false` if the widget is currently editable

### onBrowserEvent

    public void onBrowserEvent(Event event)

  Description copied from interface: `EventListener`
  Fired whenever a browser event is received.

  Specified by:
    `onBrowserEvent` in interface `EventListener`
  Overrides:
    `onBrowserEvent` in class `FocusWidget`
  Parameters:
    `event` - the event received

### removeChangeListener

    public void removeChangeListener(ChangeListener listener)

  Description copied from interface: `SourcesChangeEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeChangeListener` in interface `SourcesChangeEvents`
  Parameters:
    `listener` - the listener interface to remove

### removeClickListener

    public void removeClickListener(ClickListener listener)

  Description copied from interface: `SourcesClickEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeClickListener` in interface `SourcesClickEvents`
  Overrides:
    `removeClickListener` in class `FocusWidget`
  Parameters:
    `listener` - the listener interface to remove

### removeKeyboardListener

    public void removeKeyboardListener(KeyboardListener listener)

  Description copied from interface: `SourcesKeyboardEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeKeyboardListener` in interface `SourcesKeyboardEvents`
  Overrides:
    `removeKeyboardListener` in class `FocusWidget`
  Parameters:
    `listener` - the listener interface to remove

### 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(java.lang.String name)

  Description copied from interface: `HasName`
  Sets the widget's name.

  Specified by:
    `setName` in interface `HasName`
  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(java.lang.String text)

  Description copied from interface: `HasText`
  Sets this object's text.

  Specified by:
    `setText` in interface `HasText`
  Parameters:
    `text` - the object's new text

### setTextAlignment

    public void setTextAlignment(TextBoxBase.TextAlignConstant align)

  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`)

### getImpl

    protected com.google.gwt.user.client.ui.impl.TextBoxImpl getImpl()

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD