TextArea is a multi-line version of the TextField component described in Section 5.6, “TextField.

The following example creates a simple text area:

// Create the area
TextArea area = new TextArea("Big Area");
        
// Put some content in it
area.setValue("A row\n"+
              "Another row\n"+
              "Yet another row");

The result is shown in Figure 5.26, “TextArea Example”.


You can set the number of visible rows with setRows() or use the regular setHeight() to define the height in other units. If the actual number of rows exceeds the number, a vertical scrollbar will appear. Setting the height with setRows() leaves space for a horizontal scrollbar, so the actual number of visible rows may be one higher if the scrollbar is not visible.

You can set the width with the regular setWidth() method. Setting the size with the em unit, which is relative to the used font size, is recommended.