Java Reference
In-Depth Information
Figure 12.10
The UsedCarFrame program is used to compute the topic value of used cars.
I want you to study the GUI in Figure 12.10 and try to determine how you
might create it by using various layout managers and containers. Of course,
there is no single correct answer, but I have provided a solution in the Used-
CarFrame class available on the Web site. As you study the code, you will
notice that panels were nested within panels to create parts of the GUI.
I want to point out a few of the details of the UsedCarFrame:
The UsedCarFrame class extends JFrame, and its content pane uses
BorderLayout (because it was not changed from its default).
■■
A JPanel is added to the south, north, and center of the content pane.
■■
The JPanel in the south has FlowLayout and contains two JButton
components.
■■
The JPanel in the north has GridLayout with one row and three
columns and contains three JLabel components.
■■
The JPanel in the center of the content pane has GridLayout with one
row and three columns. The component in the first column is a JPanel
named left, the component in the second column is a JScrollPane named
scrollPane, and the component in the third column is a Box named
right.
■■
The left JPanel has GridLayout with seven rows and two columns.
The 14 components are radio buttons.
■■
The scrollPane houses a JList containing various strings.
■■
The right Box contains a JLabel, a JTextField, another JLabel, and a
JComboBox.
■■
I realize that throughout this chapter I have used the various AWT and
Swing components without properly describing them or how they are
created and used. In Chapter 13, “GUI Components and Event Handling,”
I will discuss these components in detail, including how to handle the
various events that each component generates.
Search WWH ::




Custom Search