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
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.ComponentDictionary, Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Constructor Summary
TextInput()
           
 
Method Summary
 void clearSelection()
          Clears the selection.
 void copy()
           
 void cut()
           
 void delete(Direction direction)
           
 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()
           
 ListenerList<TextInputCharacterListener> getTextInputCharacterListeners()
          Returns the text input character listener list.
 ListenerList<TextInputListener> getTextInputListeners()
          Returns the text input listener list.
 ListenerList<TextInputSelectionListener> getTextInputSelectionListeners()
          Returns the text input selection listener list.
 ListenerList<TextInputTextListener> getTextInputTextListeners()
          Returns the text input text listener list.
 String getTextKey()
          Returns the text input's text key.
 int getTextLength()
           
 TextNode getTextNode()
           
 int getTextSize()
          Returns the text size.
 Validator getValidator()
          Gets the validator associated with this text input.
 void insertText(char character, int index)
          Inserts a single character into the text input's content.
 void insertText(String text, int index)
          Inserts text into the text input's content.
 boolean isPassword()
          Returns the password flag.
 boolean isTextValid()
          Tells whether or not this text input's text is currently valid as defined by its validator.
 void load(Dictionary<String,?> context)
          Copies bound values from the bind context to the component.
 void paste()
           
 void redo()
           
 void selectAll()
          Selects all text.
 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 setText(String text)
           
 void setTextKey(String textKey)
          Sets the text input's text key.
 void setTextNode(TextNode textNode)
           
 void setTextSize(int textSize)
          Sets the text size.
 void setValidator(Validator validator)
          Sets the validator associated with this text input.
 void store(Dictionary<String,?> context)
          Copies bound values from the component to the bind context.
 void undo()
           
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, getAttributes, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponents, getComponentStateListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getGraphics, getHandle, getHeight, getLocation, getMaximumPreferredHeight, getMaximumPreferredWidth, getMenuHandler, getMinimumPreferredHeight, getMinimumPreferredWidth, getParent, getPreferredHeight, getPreferredHeight, getPreferredHeightLimits, getPreferredSize, getPreferredWidth, getPreferredWidth, getPreferredWidthLimits, getSize, getSkin, getStyles, getTooltipText, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWindow, getX, getY, installSkin, invalidate, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, load, mapPointFromAncestor, mapPointToAncestor, mouseClick, mouseDown, mouseMove, mouseOut, mouseOver, mouseUp, mouseWheel, paint, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttributes, setCursor, setCursor, setDragSource, setDropTarget, setEnabled, setHeight, setLocation, setLocation, setMaximumPreferredHeight, setMaximumPreferredWidth, setMenuHandler, setMinimumPreferredHeight, setMinimumPreferredWidth, setParent, setPreferredHeight, setPreferredHeightLimits, setPreferredHeightLimits, setPreferredSize, setPreferredSize, setPreferredWidth, setPreferredWidthLimits, setPreferredWidthLimits, setSize, setSize, setSkin, setStyles, setStyles, setStyles, setTooltipText, setVisible, setWidth, setX, setY, store, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextInput

public TextInput()
Method Detail

getTextNode

public TextNode getTextNode()

setTextNode

public void setTextNode(TextNode textNode)

getText

public String getText()

setText

public void setText(String text)

insertText

public void insertText(char character,
                       int index)
Inserts a single character into the text input's content.

Parameters:
character - The character to insert.
index - The index of the insertion point within the existing text. If equal to the current character count, the new text is appended to the existing content.

insertText

public void insertText(String text,
                       int index)
Inserts text into the text input's content.

Parameters:
text - The text to insert.
index - The index of the insertion point within the existing text. If equal to the current character count, the new text is appended to the existing content.

getTextLength

public int getTextLength()

delete

public void delete(Direction direction)

cut

public void cut()

copy

public void copy()

paste

public void paste()

undo

public void undo()

redo

public void redo()

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 is empty.

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.

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, or null if nothing is selected.

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.

load

public void load(Dictionary<String,?> 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(Dictionary<String,?> 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

isTextValid

public boolean isTextValid()
Tells whether or not this text input's text is currently valid as defined by its validator. If there is no validator associated with this text input, the text is assumed to always be valid.


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.

getTextInputListeners

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


getTextInputTextListeners

public ListenerList<TextInputTextListener> getTextInputTextListeners()
Returns the text input text listener list.


getTextInputCharacterListeners

public ListenerList<TextInputCharacterListener> getTextInputCharacterListeners()
Returns the text input character listener list.


getTextInputSelectionListeners

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