java.awt.TextArea

TextArea and TextField are nearly identical except for one rather obvious difference: A textarea provides more than one row of text, while a textfield provides only a single line of text. TextArea, like TextField, is quite generous about providing ample constructors to choose from.

  • TextArea()

  • TextArea(String)

  • TextArea(int rows, int cols)

  • TextArea(String s, int rows, int cols)

  • TextArea(String s, int rows, int cols, int scrollbarPolicy)

Of course, if you really want the textarea to be sized precisely, you should set the textarea's font to monospaced, as we advised for textareas.

The scrollbar policy passed to the last constructor listed must be one of the following:

  • TextArea.SCROLLBARS_NONE

  • TextArea.SCROLLBARS_BOTH

  • TextArea.SCROLLBARS_HORIZONTAL_ONLY ...

Get Graphic Java™ 1.2, Volume I: AWT, Third 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.