12.20 JTextArea

A JTextArea provides an area for manipulating multiple lines of text. Like class JTextField, JTextArea is a subclass of JTextComponent, which declares common methods for JTextFields, JTextAreas and several other text-based GUI components.

The application in Figs. 12.4712.48 demonstrates JTextAreas. One JTextArea displays text that the user can select. The other is uneditable by the user and is used to display the text the user selected in the first JTextArea. Unlike JTextFields, JTextAreas do not have action events—when you press Enter while typing in a JTextArea, the cursor simply moves to the next line. As with multiple-selection JLists (Section 12.13), an external event from another GUI component indicates when to process ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.