JTextArea Class
Package: javax.swing
The JTextArea class creates a text area, which is similar to a text field, but it lets the user enter more than one line of text. If the user enters more text in the text area than can be displayed at once, the text area can display a scroll bar to allow the user to see the entire text. Figure 5-12 shows a text area in action.

Figure 5-12
Constructors
|
Constructor |
Description |
|
|
Creates a new text area |
|
|
Creates a new text area large enough to display the specified number of rows and columns |
|
|
Creates a new text area with the specified initial text value, large enough to display the specified number of rows and columns |
Methods
|
Method |
Description |
|
|
Adds the specified text to the end of the text area’s text value. |
|
|
Gets the number of lines currently in the text value. |
|
|
Gets the text value entered in the field. |
|
|
Inserts the specified text at the specified position. |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access