Java Reference
In-Depth Information
A matte border specifies the sizes, in pixels, of the top, left, bottom, and right
edges of the border. Those edges can be composed of a single color, as they are in
this example, or an image icon can be used.
Borders should be used carefully. They can be helpful in drawing attention to
appropriate parts of your GUI and can conceptually group related items together.
However, if used inappropriately, they can also detract from the elegance of the pre-
sentation. Borders should enhance the interface, not complicate or compete with it.
SELF-REVIEW QUESTIONS (see answers in Appendix N)
SR 7.32 What is the role of the BorderFactory class?
SR 7.33 List and briefly describe each of the border types presented in this
section.
7.13 Containment Hierarchies
The way components are grouped into containers, and the way those containers
are nested within each other, establishes the containment hierarchy for a GUI.
We introduced this concept in Chapter 3. By carefully designing the containment
hierarchy, a GUI can be tailored to have a precise visual effect.
For any Java program, there is generally one primary container, called a top-
level container, such as a frame or applet. The top-level container of a program
often contains one or more other containers, such as panels. These panels may
contain other panels to organize the other components as desired.
Each container can have its own layout manager. The
final appearance of a GUI is a function of the layout manag-
ers chosen for each of the containers and the design of the
containment hierarchy. Many combinations are possible, and
there is rarely a single best option. As always, we should be
guided by the desired system goals and general GUI design
guidelines.
Figure 7.12 shows a GUI application that has been annotated to describe its
containment hierarchy. Several components used in this program have been dis-
cussed previously in this text; others are discussed in later chapters.
Note that in many cases, the use of some containers is not obvious just by look-
ing at the GUI. A panel, in particular, is invisible unless we draw attention to it in
some way, such as by giving it a border. We can also use invisible components to
provide specific spacing between components. These elements are all part of the
containment hierarchy, even though they are not visible to the user.
KEY CONCEPT
A GUI's appearance is a function of
the containment hierarchy and the
layout managers of each container.
 
Search WWH ::




Custom Search