Java Reference
In-Depth Information
g. A component that displays a line of text in a GUI.
h. Determines how the components in a container are arranged on
the screen.
SR 3.38 Run the Authority program. Describe what happens if you resize the
frame by dragging the bottom-right corner towards the right. Explain.
SR 3.39 Which of the following statements best describes how the GUI of the
Authority program is constructed?
A frame is added to a panel, which is added to two labels.
Labels are added to a panel, which is added to the content pane of
a frame.
Frames, panels, and labels are added to the foreground.
A panel displays two labels to the user.
SR 3.40 What is the result of separately making each of the following changes
to the Authority program? You may make the change, compile and
run the program, and observe and report the results. Briefly explain
what you observe.
a. The dimensions passed to the setPreferredSize method are
(300, 300) instead of (250, 75).
b. The background color is set to black instead of yellow.
c. The order of the two label instantiation statements is reversed (i.e.,
first you create label2 as a new JLabel , passing it the string "but
raise your hand first." , and then you create label1 as a new
JLabel , passing it the string "Question authority," ).
d. The order of the two primary add statements is reversed (i.e., first
you add label2 to the primary panel, and then you add label1) .
3.10 Nested Panels
In the previous section, we saw an example in which two labels were contained
in a panel that was contained in a frame. Such relationships make up the
contain-
ment hierarchy of an interface, which can be as intricate as needed to create the
visual effect desired.
In particular, it is common to have multiple layers of nested
panels to organize and group components in various ways. While
you shouldn't include unnecessary components in the contain-
ment hierarchy, don't hesitate to include extra scaffolding in the
creation of an interface to help achieve the effect you want.
KEY CONCEPT
Panels can be nested to create an
intricate containment hierarchy of
components.
 
Search WWH ::




Custom Search