Ok, so we know that TextField inherits all of the functionality provided by its superclass, TextComponent. A TextField, as a result, can manage selection, editable mode, and caret positioning. You can also add text listeners to a textfield and watch the text change in the field. So, let's take a look at the additional functionality TextField provides for editing its one line of text. First, take a look at the four constructors provided by the TextField class.

  1. TextField()

  2. TextField(String text)

  3. TextField(int columns)

  4. TextField(String text, int columns)

If someone were to put a gun to your head and shout “quick! what's the columns argument for, and you'd better be right!” we're pretty confident that you could calmly reel off the ...

Get Graphic Java™ 1.2, Volume I: AWT, Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.