Java Reference
In-Depth Information
*17.11
( Demonstrate JTextField properties ) Write a program that sets the horizontal-
alignment and column-size properties of a text field dynamically, as shown in
Figure 17.25b.
*17.12
( Demonstrate JTextArea properties ) Write a program that demonstrates the
wrapping styles of the text area. The program uses a check box to indicate whether
the text area is wrapped. If the text area is wrapped, you can specify whether it is
wrapped by characters or by words, as shown in Figure 17.26.
VideoNote
Use text areas
JTextArea inside
a scroll pane
Panel with
FlowLayout
F IGURE 17.26
You can set the options to wrap a text area dynamically by characters or by
words.
*17.13
( Compare loans with various interest rates ) Rewrite Programming Exercise 4.21
to create a user interface, as shown in Figure 17.27. Your program should let the
user enter the loan amount and loan period in the number of years from a text field,
and it should display the monthly and total payments for each interest rate starting
from 5 percent to 8 percent, with increments of one-eighth, in a text area.
Panel with
FlowLayout
JTextArea inside
a scroll pane
F IGURE 17.27 The program displays a table for monthly payments and total payments on a
given loan based on various interest rates.
*17.14
( Use JComboBox and JList ) Write a program that demonstrates selecting items
in a list. The program uses a combo box to specify a selection mode, as shown in
Figure 17.28. When you select items, they are displayed in a label below the list.
JComboBox
JList inside a
scroll pane
JLabel
F IGURE 17.28 You can choose single selection, single-interval selection, or multiple-interval
selection in a list.
Search WWH ::




Custom Search