A text field is a basic text control that enables the user to type a small amount of text. When the user indicates that text entry is complete (usually by pressing Enter), the text field fires an action event. If you need to obtain more than one line of input from the user, use a text area.
The Swing API provides several classes for components that are either varieties of text fields or that include text fields.
||What this section covers: basic text fields.
||A JTextField subclass that allows you to specify the legal set of characters that the user can enter. See How to Use Formatted Text Fields.
||A JTextField subclass that does not show the characters that the user types.
||Can be edited, and provides a menu of strings to choose from.
||Combines a formatted text field with a couple of small buttons that enables the user to choose the previous or next available value.
public class swing2 extends JApplet
public void init()
Container contentPane = getContentPane();
jtf = new JTextField(15);
Output in applet