Package org.apache.pivot.wtk
Class TextArea
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- 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
Nested Classes Modifier and Type Class Description static classTextArea.ParagraphClass representing a paragraph of text.static interfaceTextArea.ParagraphListenerParagraph listener interface.classTextArea.ParagraphSequenceText area paragraph sequence.static classTextArea.ScrollDirectionEnum representing a scroll direction.static interfaceTextArea.SkinText area skin interface.static interfaceTextArea.TextBindMappingTranslates 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
Constructors Constructor Description TextArea()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears any bound values in the component.voidclearSelection()Clears the selection.voidcopy()Places any selected text on the clipboard.voidcut()Places any selected text on the clipboard and deletes it from the text input.chargetCharacterAt(int index)BoundsgetCharacterBounds(int index)intgetCharacterCount()java.lang.CharSequencegetCharacters()java.lang.CharSequencegetCharacters(int start, int end)CharSpangetCharSelection()Returns a character span (start, length) representing the current selection.AttributedStringCharacterIteratorgetComposedText()Return the current text that is in process of being composed using the Input Method Editor.booleangetExpandTabs()intgetInsertionPoint(int x, int y)intgetMaximumLength()intgetNextInsertionPoint(int x, int from, TextArea.ScrollDirection direction)intgetParagraphAt(int index)TextArea.ParagraphSequencegetParagraphs()intgetRowAt(int index)java.lang.CharSequencegetRowCharacters(int index)intgetRowCount()intgetRowLength(int index)intgetRowOffset(int index)java.lang.StringgetSelectedText()Returns the selected text.SpangetSelection()Returns a span representing the current selection.intgetSelectionLength()intgetSelectionStart()java.lang.StringgetText()Returns the text content of the text area.java.lang.StringgetText(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.TextBindMappinggetTextBindMapping()BindTypegetTextBindType()java.lang.StringgetTextKey()Returns the text area's text key.voidinsertText(java.lang.CharSequence text, int index)booleanisEditable()voidload(java.lang.Object context)Copies bound values from the bind context to the component.voidpaste()Inserts text from the clipboard into the text input.voidremoveText(int index, int count)voidremoveText(CharSpan charSelection)voidselectAll()Selects all text.voidsetComposedText(AttributedStringCharacterIterator currentComposedText)Called from the Input Method Editor callbacks to set the current composed text (that is, the text currently being composed into something meaningful).voidsetEditable(boolean editableValue)Sets the text area's editable flag.voidsetExpandTabs(boolean expandValue)Sets whether tab characters (\t) are expanded to an appropriate number of spaces duringsetText(java.lang.String)andinsertText(java.lang.CharSequence, int)operations.voidsetMaximumLength(int newMaximum)Sets the maximum length of the text area's text content.voidsetSelection(int newStart, int newLength)Sets the selection.voidsetSelection(CharSpan selection)Sets the selection.voidsetSelection(Span selection)Sets the selection.protected voidsetSkin(Skin skin)Sets the skin, replacing any previous skin.voidsetText(java.io.File f)voidsetText(java.io.File f, java.nio.charset.Charset cs)voidsetText(java.io.Reader textReader)voidsetText(java.lang.String text)Sets the text content of the text area.voidsetText(java.net.URL textURL)voidsetTextBindMapping(TextArea.TextBindMapping newTextBindMapping)voidsetTextBindType(BindType newTextBindType)voidsetTextKey(java.lang.String newTextKey)Sets the text area's text key.voidstore(java.lang.Object context)Copies bound values from the component to the bind context.voidundo()-
Methods inherited from class org.apache.pivot.wtk.Component
checkSkin, clearFocus, contains, copyStyle, copyStyle, 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, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, 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, offsetToScreen, paint, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, repaint, requestFocus, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, 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
-
-
-
-
Method Detail
-
setSkin
protected void setSkin(Skin skin)
Description copied from class:ComponentSets the skin, replacing any previous skin.
-
getText
public java.lang.String getText()
Returns the text content of the text area.- Returns:
- A string containing a copy of the text area's text content.
-
getComposedText
public AttributedStringCharacterIterator getComposedText()
Return the current text that is in process of being composed using the Input Method Editor. This is temporary text that must be displayed, scrolled, etc. but is not a permanent part of what would be returned fromgetText()for instance.- Returns:
- The current composed text or
nullif we're not using an IME or we're in English input mode, or user just committed or deleted the composed text.
-
setComposedText
public void setComposedText(AttributedStringCharacterIterator currentComposedText)
Called from the Input Method Editor callbacks to set the current composed text (that is, the text currently being composed into something meaningful).- Parameters:
currentComposedText- The current composed text (which can benullfor many different reasons).
-
getText
public java.lang.String getText(int beginIndex, int endIndex)Returns a portion of the text content of the text area.- Parameters:
beginIndex- The beginning location (inclusive) to obtain text from.endIndex- The ending location (exclusive) of the text segment to fetch.- Returns:
- A string containing a copy of the text area's text content.
-
getCharacters
public java.lang.CharSequence getCharacters()
- Returns:
- A character sequence representing the text input's content.
-
getCharacters
public java.lang.CharSequence getCharacters(int start, int end)- Parameters:
start- The start of the sequence (inclusive).end- The end of the sequence (exclusive).- Returns:
- A (sub) character sequence representing the contents between the given indices.
-
setText
public void setText(java.lang.String text)
Sets the text content of the text area.- Parameters:
text- The new text for the control (cannot benull).
-
setText
public void setText(java.net.URL textURL) throws java.io.IOException- Throws:
java.io.IOException
-
setText
public void setText(java.io.File f) throws java.io.IOException- Throws:
java.io.IOException
-
setText
public void setText(java.io.File f, java.nio.charset.Charset cs) throws java.io.IOException- Throws:
java.io.IOException
-
setText
public void setText(java.io.Reader textReader) throws java.io.IOException- Throws:
java.io.IOException
-
insertText
public void insertText(java.lang.CharSequence text, int index)
-
removeText
public void removeText(CharSpan charSelection)
-
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)
- Parameters:
index- The character index to check ([0..characterCount]).- Returns:
- The index of the paragraph containing a given character index.
-
getCharacterAt
public char getCharacterAt(int index)
- Parameters:
index- The index of the character to fetch ([0..characterCount-1]).- Returns:
- The character at a given 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.
-
getSelectionLength
public int getSelectionLength()
- 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
nullif the selection is empty.
-
getCharSelection
public CharSpan getCharSelection()
Returns a character span (start, length) representing the current selection.- Returns:
- A char span with the start and length values.
-
setSelection
public void setSelection(int newStart, int newLength)Sets the selection. The sum of the selection start and length must be less than the length of the text area's content.- Parameters:
newStart- The starting index of the selection.newLength- The length of the selection.
-
setSelection
public final void setSelection(Span selection)
Sets the selection.- Parameters:
selection- The new span of text to select.- See Also:
setSelection(int, int)
-
setSelection
public final void setSelection(CharSpan selection)
Sets the selection.- Parameters:
selection- The character span (start and length) for the selection.- Throws:
java.lang.IllegalArgumentException- if the character span isnull.- See Also:
setSelection(int, int)
-
selectAll
public void selectAll()
Selects all text.
-
clearSelection
public void clearSelection()
Clears the selection.
-
getSelectedText
public java.lang.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.
-
setMaximumLength
public void setMaximumLength(int newMaximum)
Sets the maximum length of the text area's text content.- Parameters:
newMaximum- 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 editableValue)
Sets the text area's editable flag.- Parameters:
editableValue- Whether or not the text should now be editable.
-
getTextKey
public java.lang.String getTextKey()
Returns the text area's text key.- Returns:
- The text key, or
nullif no text key is set.
-
setTextKey
public void setTextKey(java.lang.String newTextKey)
Sets the text area's text key.- Parameters:
newTextKey- The text key, ornullto clear the binding.
-
getTextBindType
public BindType getTextBindType()
-
setTextBindType
public void setTextBindType(BindType newTextBindType)
-
getTextBindMapping
public TextArea.TextBindMapping getTextBindMapping()
-
setTextBindMapping
public void setTextBindMapping(TextArea.TextBindMapping newTextBindMapping)
-
load
public void load(java.lang.Object context)
Description copied from class:ComponentCopies bound values from the bind context to the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
store
public void store(java.lang.Object context)
Description copied from class:ComponentCopies bound values from the component to the bind context. This functionality must be provided by the subclass; the base implementation is a no-op.
-
clear
public void clear()
Description copied from class:ComponentClears any bound values in the component. This functionality must be provided by the subclass; the base implementation is a no-op.
-
getExpandTabs
public boolean getExpandTabs()
-
setExpandTabs
public void setExpandTabs(boolean expandValue)
Sets whether tab characters (\t) are expanded to an appropriate number of spaces duringsetText(java.lang.String)andinsertText(java.lang.CharSequence, int)operations.- Parameters:
expandValue-trueto replace tab characters with space characters (depending on the setting of theTextArea.Skin.getTabWidth()value) orfalseto 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)
-
getRowCharacters
public java.lang.CharSequence getRowCharacters(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()
-
-