org.apache.pivot.wtk
Class TextArea

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.TextArea
All Implemented Interfaces:
ConstrainedVisual, Visual
Direct Known Subclasses:
TableViewTextAreaCellRenderer

public class TextArea
extends Component

A component that allows a user to enter multiple lines of unformatted text.


Nested Class Summary
static class TextArea.Paragraph
          Class representing a paragraph of text.
static interface TextArea.ParagraphListener
          Paragraph listener interface.
 class TextArea.ParagraphSequence
          Text area paragraph sequence.
static class TextArea.ScrollDirection
          Enum representing a scroll direction.
static interface TextArea.Skin
          Text area skin interface.
static interface TextArea.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
 
Constructor Summary
TextArea()
           
 
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 area, including line break characters.
 boolean getExpandTabs()
           
 int getInsertionPoint(int x, int y)
           
 int getMaximumLength()
          Returns the maximum length of the text area's text content.
 int getNextInsertionPoint(int x, int from, TextArea.ScrollDirection direction)
           
 int getParagraphAt(int index)
          Returns the index of the paragraph containing a given character index.
 TextArea.ParagraphSequence getParagraphs()
          Returns the text area's paragraph sequence.
 int getRowAt(int index)
           
 int getRowCount()
           
 int getRowLength(int index)
           
 int getRowOffset(int index)
           
 String getSelectedText()
          Returns the 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 area.
 String getText(int beginIndex, int endIndex)
          Returns a portion of the text content of the text area.
 ListenerList<TextAreaBindingListener> getTextAreaBindingListeners()
           
 ListenerList<TextAreaContentListener> getTextAreaContentListeners()
           
 ListenerList<TextAreaListener> getTextAreaListeners()
           
 ListenerList<TextAreaSelectionListener> getTextAreaSelectionListeners()
           
 TextArea.TextBindMapping getTextBindMapping()
           
 BindType getTextBindType()
           
 String getTextKey()
          Returns the text area's text key.
 void insertText(CharSequence text, int index)
           
 boolean isEditable()
          Returns the text area's editable flag.
 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 setExpandTabs(boolean expandTabs)
          Sets whether tab characters (\t) are expanded to an appropriate number of spaces during setText(java.lang.String) and insertText(java.lang.CharSequence, int) operations.
 void setMaximumLength(int maximumLength)
          Sets the maximum length of the text area's text content.
 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 setText(Reader textReader)
           
 void setText(String text)
          Sets the text content of the text area.
 void setText(URL textURL)
           
 void setTextBindMapping(TextArea.TextBindMapping textBindMapping)
           
 void setTextBindType(BindType textBindType)
           
 void setTextKey(String textKey)
          Sets the text area's text key.
 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
 

Constructor Detail

TextArea

public TextArea()
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 area.

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

getText

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

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

setText

public void setText(String text)
Sets the text content of the text area.

Parameters:
text -

setText

public void setText(URL textURL)
             throws IOException
Throws:
IOException

setText

public void setText(Reader textReader)
             throws IOException
Throws:
IOException

insertText

public void insertText(CharSequence text,
                       int index)

removeText

public void removeText(int index,
                       int count)

getParagraphs

public TextArea.ParagraphSequence getParagraphs()
Returns the text area's paragraph sequence.


getParagraphAt

public int getParagraphAt(int index)
Returns the index of the paragraph containing a given character index.

Parameters:
index -

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 area, including line break characters.


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 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 area'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 selected text.

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

getMaximumLength

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

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

setMaximumLength

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

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

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 -

getTextKey

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

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

setTextKey

public void setTextKey(String textKey)
Sets the text area'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 TextArea.TextBindMapping getTextBindMapping()

setTextBindMapping

public void setTextBindMapping(TextArea.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

getExpandTabs

public boolean getExpandTabs()

setExpandTabs

public void setExpandTabs(boolean expandTabs)
Sets whether tab characters (\t) are expanded to an appropriate number of spaces during setText(java.lang.String) and insertText(java.lang.CharSequence, int) operations.

Parameters:
expandTabs - true to replace tab characters with space characters (depending on the setting of the TextArea.Skin.getTabWidth() value) or false to leave tabs alone. Note: this only affects tabs encountered during program operations; tabs entered via the keyboard by the user are always expanded, regardless of this setting.

getInsertionPoint

public int getInsertionPoint(int x,
                             int y)

getNextInsertionPoint

public int getNextInsertionPoint(int x,
                                 int from,
                                 TextArea.ScrollDirection direction)

getRowAt

public int getRowAt(int index)

getRowOffset

public int getRowOffset(int index)

getRowLength

public int getRowLength(int index)

getRowCount

public int getRowCount()

getCharacterBounds

public Bounds getCharacterBounds(int index)

getTextAreaListeners

public ListenerList<TextAreaListener> getTextAreaListeners()

getTextAreaContentListeners

public ListenerList<TextAreaContentListener> getTextAreaContentListeners()

getTextAreaSelectionListeners

public ListenerList<TextAreaSelectionListener> getTextAreaSelectionListeners()

getTextAreaBindingListeners

public ListenerList<TextAreaBindingListener> getTextAreaBindingListeners()