Java Reference
In-Depth Information
b. The saying is not visible. You just see a black panel because the
saying, which is written in black, blends in with the background.
c. There is no change.
d. Since the labels are added in the opposite order, the saying is “back-
wards”—that is, it reads “but raise your hand first.” followed by
“Question authority.”
3.10 Nested Panels
SR 3.41
The containment hierarchy of a graphical user interface identifies the
nesting of elements within the GUI. For example, in a particular GUI,
suppose some labels and buttons are contained within a panel that is
contained within another panel that is contained within a frame. The
containment hierarchy can be represented as a tree that indicates how
all the elements of a GUI are nested within each other.
SR 3.42
In the NestedPanels program, there are three panels created: sub-
Panel1 , subPanel2 , and primary .
SR 3.43
In the NestedPanels program, subPanel1 and subPanel2 are added to
the primary panel. The primary panel is explicitly added to the content
pane of the frame.
3.11 Images
SR 3.44 One frame, one panel, one image icon, and three labels are declared in
the LabelDemo program.
SR 3.45 In the label instantiation statement from the LabelDemo program:
label2 = new JLabel ("Devil Right", icon, SwingConstants.CENTER);
the first parameter defines the text, the second parameter provides the
image, and the third parameter indicates the horizontal alignment of the
label.
SR 3.46
The results of the changes are:
a. Changing the horizontal alignment of the labels has no visual
effect. The horizontal alignment describes only how text and icons
are aligned within a label. Since a label's area is typically exactly
the size needed to display the label, label alignment within that
area is irrelevant.
b. The change in the text position results in the text “Devil Right”
appearing to the right of the second image, instead of to its left.
Search WWH ::




Custom Search