org.apache.pivot.wtk
Class TextInput

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.TextInput
All Implemented Interfaces:
ConstrainedVisual, Visual

public class TextInput
extends Component

A component that allows a user to enter a single line of unformatted text.


Nested Class Summary
static interface TextInput.Skin
          Text input skin interface.
static interface TextInput.TextBindMapping
          Translates between text and context data during data binding.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Field Summary
static int DEFAULT_TEXT_SIZE
           
 
Constructor Summary
TextInput()
           
 
Method Summary
 void clear()
          Clears any bound values in the component.
 void clearSelection()
          Clears the selection.
 void copy()
          Places any selected text on the clipboard.
 void cut()
          Places any selected text on the clipboard and deletes it from the text input.
 char getCharacterAt(int index)
          Returns the character at a given index.
 Bounds getCharacterBounds(int index)
           
 int getCharacterCount()
          Returns the number of characters in the text input.
 CharSequence getCharacters()
          Returns a character sequence representing the text input's content.
 int getInsertionPoint(int x)
           
 int getMaximumLength()
          Returns the maximum length of the text input's text content.
 String getPrompt()
          Returns the text input's prompt.
 String getSelectedText()
          Returns the currently selected text.
 Span getSelection()
          Returns a span representing the current selection.
 int getSelectionLength()
          Returns the length of the selection.
 int getSelectionStart()
          Returns the starting index of the selection.
 String getText()
          Returns the text content of the text input.
 String getText(int beginIndex, int endIndex)
          Returns a portion of the text content of the text input.
 TextInput.TextBindMapping getTextBindMapping()
           
 BindType getTextBindType()
           
 ListenerList<TextInputBindingListener> getTextInputBindingListeners()
          Returns the text input binding listener list.
 ListenerList<TextInputContentListener> getTextInputContentListeners()
          Returns the text input text listener list.
 ListenerList<TextInputListener> getTextInputListeners()
          Returns the text input listener list.
 ListenerList<TextInputSelectionListener> getTextInputSelectionListeners()
          Returns the text input selection listener list.
 String getTextKey()
          Returns the text input's text key.
 int getTextSize()
          Returns the text size.
 Validator getValidator()
          Gets the validator associated with this text input.
 void insertText(CharSequence text, int index)
           
 boolean isEditable()
          Returns the text area's editable flag.
 boolean isPassword()
          Returns the password flag.
 boolean isStrictValidation()
          Returns the text input's strict validation flag.
 boolean isTextValid()
          Reports whether this text input's text is currently valid as defined by its validator.
 void load(Object context)
          Copies bound values from the bind context to the component.
 void paste()
          Inserts text from the clipboard into the text input.
 void removeText(int index, int count)
           
 void selectAll()
          Selects all text.
 void setEditable(boolean editable)
          Sets the text area's editable flag.
 void setMaximumLength(int maximumLength)
          Sets the maximum length of the text input's text content.
 void setPassword(boolean password)
          Sets or clears the password flag.
 void setPrompt(String prompt)
          Sets the text input's prompt.
 void setSelection(int selectionStart, int selectionLength)
          Sets the selection.
 void setSelection(Span selection)
          Sets the selection.
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 void setStrictValidation(boolean strictValidation)
          Sets the text input's strict validation flag.
 void setText(String text)
           
 void setTextBindMapping(TextInput.TextBindMapping textBindMapping)
           
 void setTextBindType(BindType textBindType)
           
 void setTextKey(String textKey)
          Sets the text input's text key.
 void setTextSize(int textSize)
          Sets the text size.
 void setValidator(Validator validator)
          Sets the validator associated with this text input.
 void store(Object context)
          Copies bound values from the component to the bind context.
 void undo()
           
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, contains, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, layout, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, paint, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setParent, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setVisible, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_TEXT_SIZE

public static final int DEFAULT_TEXT_SIZE
See Also:
Constant Field Values
Constructor Detail

TextInput

public TextInput()
Method Detail

setSkin

protected void setSkin(Skin skin)
Description copied from class: Component
Sets the skin, replacing any previous skin.

Overrides:
setSkin in class Component
Parameters:
skin - The new skin.

getText

public String getText()
Returns the text content of the text input.

Returns:
A string containing a copy of the text input's text content.

getText

public String getText(int beginIndex,
                      int endIndex)
Returns a portion of the text content of the text input.

Parameters:
beginIndex -
endIndex -
Returns:
A string containing a copy of the text area's text content.

setText

public void setText(String text)

insertText

public void insertText(CharSequence text,
                       int index)

removeText

public void removeText(int index,
                       int count)

getCharacters

public CharSequence getCharacters()
Returns a character sequence representing the text input's content.


getCharacterAt

public char getCharacterAt(int index)
Returns the character at a given index.

Parameters:
index -

getCharacterCount

public int getCharacterCount()
Returns the number of characters in the text input.


cut

public void cut()
Places any selected text on the clipboard and deletes it from the text input.


copy

public void copy()
Places any selected text on the clipboard.


paste

public void paste()
Inserts text from the clipboard into the text input.


undo

public void undo()

getSelectionStart

public int getSelectionStart()
Returns the starting index of the selection.

Returns:
The starting index of the selection.

getSelectionLength

public int getSelectionLength()
Returns the length of the selection.

Returns:
The length of the selection; may be 0.

getSelection

public Span getSelection()
Returns a span representing the current selection.

Returns:
A span containing the current selection. Both start and end points are inclusive. Returns null if the selection length is 0.

setSelection

public void setSelection(int selectionStart,
                         int selectionLength)
Sets the selection. The sum of the selection start and length must be less than the length of the text input's content.

Parameters:
selectionStart - The starting index of the selection.
selectionLength - The length of the selection.

setSelection

public final void setSelection(Span selection)
Sets the selection.

Parameters:
selection -
See Also:
setSelection(int, int)

selectAll

public void selectAll()
Selects all text.


clearSelection

public void clearSelection()
Clears the selection.


getSelectedText

public String getSelectedText()
Returns the currently selected text.

Returns:
A new string containing a copy of the text in the selected range.

getTextSize

public int getTextSize()
Returns the text size.

Returns:
The number of characters to display in the text input.

setTextSize

public void setTextSize(int textSize)
Sets the text size.

Parameters:
textSize - The number of characters to display in the text input.

getMaximumLength

public int getMaximumLength()
Returns the maximum length of the text input's text content.

Returns:
The maximum length of the text input's text content.

setMaximumLength

public void setMaximumLength(int maximumLength)
Sets the maximum length of the text input's text content.

Parameters:
maximumLength - The maximum length of the text input's text content.

isPassword

public boolean isPassword()
Returns the password flag.

Returns:
true if this is a password text input; false, otherwise.

setPassword

public void setPassword(boolean password)
Sets or clears the password flag. If the password flag is set, the text input will visually mask its contents.

Parameters:
password - true if this is a password text input; false, otherwise.

getPrompt

public String getPrompt()
Returns the text input's prompt.


setPrompt

public void setPrompt(String prompt)
Sets the text input's prompt.

Parameters:
prompt - The prompt text, or null for no prompt.

getTextKey

public String getTextKey()
Returns the text input's text key.

Returns:
The text key, or null if no text key is set.

setTextKey

public void setTextKey(String textKey)
Sets the text input's text key.

Parameters:
textKey - The text key, or null to clear the binding.

getTextBindType

public BindType getTextBindType()

setTextBindType

public void setTextBindType(BindType textBindType)

getTextBindMapping

public TextInput.TextBindMapping getTextBindMapping()

setTextBindMapping

public void setTextBindMapping(TextInput.TextBindMapping textBindMapping)

load

public void load(Object context)
Description copied from class: Component
Copies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.

Overrides:
load in class Component

store

public void store(Object context)
Description copied from class: Component
Copies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.

Overrides:
store in class Component

clear

public void clear()
Description copied from class: Component
Clears any bound values in the component.

Overrides:
clear in class Component

getInsertionPoint

public int getInsertionPoint(int x)

getCharacterBounds

public Bounds getCharacterBounds(int index)

getValidator

public Validator getValidator()
Gets the validator associated with this text input.


setValidator

public void setValidator(Validator validator)
Sets the validator associated with this text input.

Parameters:
validator - The validator to use, or null to use no validator.

isStrictValidation

public boolean isStrictValidation()
Returns the text input's strict validation flag.


setStrictValidation

public void setStrictValidation(boolean strictValidation)
Sets the text input's strict validation flag. When enabled, only valid text will be accepted by the text input.

Parameters:
strictValidation -

isTextValid

public boolean isTextValid()
Reports whether this text input's text is currently valid as defined by its validator.

Returns:
true if the text is valid or no validator is installed; false, otherwise.

isEditable

public boolean isEditable()
Returns the text area's editable flag.


setEditable

public void setEditable(boolean editable)
Sets the text area's editable flag.

Parameters:
editable -

getTextInputListeners

public ListenerList<TextInputListener> getTextInputListeners()
Returns the text input listener list.


getTextInputContentListeners

public ListenerList<TextInputContentListener> getTextInputContentListeners()
Returns the text input text listener list.


getTextInputSelectionListeners

public ListenerList<TextInputSelectionListener> getTextInputSelectionListeners()
Returns the text input selection listener list.


getTextInputBindingListeners

public ListenerList<TextInputBindingListener> getTextInputBindingListeners()
Returns the text input binding listener list.