Java Reference
In-Depth Information
Working with Scroll Panes (continued)
Figure 13.9
Both scroll bars in the JTextArea.
If you are using JTextArea with a JScrollPane, be sure to check the documentation of
ScrollPaneConstants for the other possible scroll bar policies.
The JPasswordField class is used for the common occurrence of a user need-
ing to enter a password. A JPasswordField is similar to a JTextField except the
characters typed in by the user are not echoed back to the user. Instead, an
alternate character such as an asterisk is displayed for each character typed in
the field. You can set the echo character using the method:
public void setEchoChar(char c)
The JTextComponentDemo program available on the Web site demonstrates
using the Swing text components JTextField, JPasswordField, and JLabel.
Study the program and try to determine how the GUI will look. The output is
shown in Figure 13.10. Notice that this program does not contain any event
handling. It demonstrates, however, the power of using panels and layout
managers to obtain the specific GUI you want.
Figure 13.10
GUI created from the JTextComponentDemo program.
Search WWH ::




Custom Search