java.awt.TextField

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