O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required