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:
TextField
  • 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.
      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.
    • prefColumnCountProperty

      public final IntegerProperty prefColumnCountProperty()
      The preferred number of text columns. This is used for calculating the TextArea's preferred width.
      See Also:
      getPrefColumnCount(), setPrefColumnCount(int)
    • 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.
    • prefRowCountProperty

      public final IntegerProperty prefRowCountProperty()
      The preferred number of text rows. This is used for calculating the TextArea's preferred height.
      See Also:
      getPrefRowCount(), setPrefRowCount(int)
    • 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.
    • scrollTopProperty

      public final DoubleProperty scrollTopProperty()
      The number of pixels by which the content is vertically scrolled.
      See Also:
      getScrollTop(), setScrollTop(double)
    • 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.
    • scrollLeftProperty

      public final DoubleProperty scrollLeftProperty()
      The number of pixels by which the content is horizontally scrolled.
      See Also:
      getScrollLeft(), setScrollLeft(double)
    • 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.
    • createDefaultSkin

      protected Skin<?> createDefaultSkin()
      Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).
      Overrides:
      createDefaultSkin in class Control
      Returns:
      new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
    • 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
    • getControlCssMetaData

      public List<CssMetaData<? extends Styleable,​?>> getControlCssMetaData()
      Overrides:
      getControlCssMetaData in class TextInputControl
      Returns:
      unmodifiable list of the controls css styleable properties
      Since:
      JavaFX 8.0