Class TextArea

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public class TextArea
    extends TextInputControl
    Text input component that allows a user to enter multiple lines of plain text. Unlike in previous releases of JavaFX, support for single line input is not available as part of the TextArea control, however this is the sole-purpose of the TextField control. Additionally, if you want a form of rich-text editing, there is also the HTMLEditor control.

    TextArea supports the notion of showing prompt text to the user when there is no text already in the TextArea (either via the user, or set programmatically). This is a useful way of informing the user as to what is expected in the text area, without having to resort to tooltips or on-screen labels.

    Since:
    JavaFX 2.0
    See Also:
    TextField
    • Constructor Detail

      • TextArea

        public TextArea()
        Creates a TextArea with empty text content.
      • TextArea

        public TextArea​(String text)
        Creates a TextArea with initial text content.
        Parameters:
        text - A string for text content.
    • Method Detail

      • getParagraphs

        public ObservableList<CharSequence> getParagraphs()
        Returns an unmodifiable list of the character sequences that back the text area's content.
        Returns:
        an unmodifiable list of the character sequences that back the text area's content
      • wrapTextProperty

        public final BooleanProperty wrapTextProperty()
        If a run of text exceeds the width of the TextArea, then this variable indicates whether the text should wrap onto another line.
        See Also:
        isWrapText(), setWrapText(boolean)
      • isWrapText

        public final boolean isWrapText()
        Gets the value of the property wrapText.
        Property description:
        If a run of text exceeds the width of the TextArea, then this variable indicates whether the text should wrap onto another line.
      • setWrapText

        public final void setWrapText​(boolean value)
        Sets the value of the property wrapText.
        Property description:
        If a run of text exceeds the width of the TextArea, then this variable indicates whether the text should wrap onto another line.
      • getPrefColumnCount

        public final int getPrefColumnCount()
        Gets the value of the property prefColumnCount.
        Property description:
        The preferred number of text columns. This is used for calculating the TextArea's preferred width.
      • setPrefColumnCount

        public final void setPrefColumnCount​(int value)
        Sets the value of the property prefColumnCount.
        Property description:
        The preferred number of text columns. This is used for calculating the TextArea's preferred width.
      • getPrefRowCount

        public final int getPrefRowCount()
        Gets the value of the property prefRowCount.
        Property description:
        The preferred number of text rows. This is used for calculating the TextArea's preferred height.
      • setPrefRowCount

        public final void setPrefRowCount​(int value)
        Sets the value of the property prefRowCount.
        Property description:
        The preferred number of text rows. This is used for calculating the TextArea's preferred height.
      • getScrollTop

        public final double getScrollTop()
        Gets the value of the property scrollTop.
        Property description:
        The number of pixels by which the content is vertically scrolled.
      • setScrollTop

        public final void setScrollTop​(double value)
        Sets the value of the property scrollTop.
        Property description:
        The number of pixels by which the content is vertically scrolled.
      • getScrollLeft

        public final double getScrollLeft()
        Gets the value of the property scrollLeft.
        Property description:
        The number of pixels by which the content is horizontally scrolled.
      • setScrollLeft

        public final void setScrollLeft​(double value)
        Sets the value of the property scrollLeft.
        Property description:
        The number of pixels by which the content is horizontally scrolled.
      • getClassCssMetaData

        public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
        Returns:
        The CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
        Since:
        JavaFX 8.0