We are finally ready to start introducing the Swing user interface components. We'll start with components that let a user input and edit text. In Java, two components are used to get text input: text fields and text areas. The difference between them is that a text field can accept only one line of text and a text area can accept multiple lines of text. The classes are called JTextField for single-line input and JTextArea for multiple lines of text. Both of these classes inherit from a class called JTextComponent. You will not be able to construct a JTextComponent yourself since it is an abstract class. On the other hand, as is so often the case in Java, when you go searching through the API documentation, you may find that the methods you are looking for are actually in the parent class JTextComponent rather than in the derived class. For example, the methods that get or set the text in a text field or text area are actually methods in JTextComponent.

javax.swing.text.JTextComponent 1.2

Java graphics api_icon