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.

Example:

 var textArea = new TextArea("Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
        + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim "
        + "ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip "
        + "ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate "
        + "velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat "
        + "cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
 textArea.setWrapText(true);
Image of the TextArea control
Since:
JavaFX 2.0
See Also:
  • Property Details

  • Field Details

  • Constructor Details

    • 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 Details

    • 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.
      Returns:
      the wrapText property
      See Also:
    • isWrapText

      public final boolean isWrapText()
      Gets the value of the wrapText property.
      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.
      Returns:
      the value of the wrapText property
      See Also:
    • setWrapText

      public final void setWrapText(boolean value)
      Sets the value of the wrapText property.
      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.
      Parameters:
      value - the value for the wrapText property
      See Also:
    • prefColumnCountProperty

      public final IntegerProperty prefColumnCountProperty()
      The preferred number of text columns. This is used for calculating the TextArea's preferred width.
      Returns:
      the prefColumnCount property
      See Also:
    • getPrefColumnCount

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

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

      public final IntegerProperty prefRowCountProperty()
      The preferred number of text rows. This is used for calculating the TextArea's preferred height.
      Returns:
      the prefRowCount property
      See Also:
    • getPrefRowCount

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

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

      public final DoubleProperty scrollTopProperty()
      The number of pixels by which the content is vertically scrolled.
      Returns:
      the scrollTop property
      See Also:
    • getScrollTop

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

      public final void setScrollTop(double value)
      Sets the value of the scrollTop property.
      Property description:
      The number of pixels by which the content is vertically scrolled.
      Parameters:
      value - the value for the scrollTop property
      See Also:
    • scrollLeftProperty

      public final DoubleProperty scrollLeftProperty()
      The number of pixels by which the content is horizontally scrolled.
      Returns:
      the scrollLeft property
      See Also:
    • getScrollLeft

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

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

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

      public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
      Gets the unmodifiable list of the control's CSS-styleable properties.
      Overrides:
      getControlCssMetaData in class TextInputControl
      Returns:
      the unmodifiable list of the control's CSS-styleable properties
      Since:
      JavaFX 8.0