Class TextArea

    • 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 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 from getText() for instance.
        Returns:
        The current composed text or null if 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 be null for 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 be null).
      • 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)
      • 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 null if 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 is null.
        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 null if 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, or null to clear the binding.
      • getTextBindType

        public BindType getTextBindType()
      • setTextBindType

        public void setTextBindType​(BindType newTextBindType)
      • load

        public void load​(java.lang.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
        Parameters:
        context - The object to load the bound values from.
      • store

        public void store​(java.lang.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
        Parameters:
        context - The object to store the bound values into.
      • clear

        public void clear()
        Description copied from class: Component
        Clears any bound values in the component. This functionality must be provided by the subclass; the base implementation is a no-op.
        Overrides:
        clear in class Component
      • getExpandTabs

        public boolean getExpandTabs()
      • setExpandTabs

        public void setExpandTabs​(boolean expandValue)
        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:
        expandValue - 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)
      • 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)