Java Reference
In-Depth Information
task. Using keyboard shortcuts (mnemonics) is a good example. Sometimes these
additional mechanisms are less intuitive, but they may be faster for the experienced
user.
Finally, consistency is important when dealing with large systems or multiple
systems in a common environment. Users become familiar with a particular orga-
nization or color scheme; these should not be changed arbitrarily.
SELF-REVIEW QUESTIONS (see answers in Appendix N)
SR 7.26 What general guidelines for GUI design are presented in this section?
SR 7.27 Why is a good user interface design so important?
7.11 Layout Managers
In addition to the components, events, and listeners that comprise the backbone
of a GUI, the most important activity in GUI design is the use of layout manag-
ers. A layout manager is an object that governs how components are arranged in
a container. It determines the size and position of each component and may take
many factors into account to do so. Every container has a default layout manager,
although we can replace it if we prefer another one.
A container's layout manager is consulted whenever
a change to the visual appearance of its contents might
be needed. When the size of a container is adjusted, for
example, the layout manager is consulted to determine how
all of the components in the container should appear in the
resized container. Every time a component is added to a con-
tainer, the layout manager determines how the addition affects all of the existing
components.
KEY CONCEPT
The layout manager of a container
determines how components are
visually presented.
The table in Figure 7.6 describes several of the predefined
layout managers provided by the Java standard class library.
Every layout manager has its own particular properties
and rules governing the layout of components. For some
layout managers, the order in which you add the compo-
nents affects their positioning, whereas others provide more
specific control. Some layout managers take a component's preferred size or
alignment into account, whereas others don't. To develop good GUIs in Java, it is
important to become familiar with features and characteristics of various layout
managers.
We can use the setLayout method of a container to change its layout manager.
We've done this a few times in previous examples. For example, the following
KEY CONCEPT
When changes occur, the compo-
nents in a container reorganize
themselves according to the layout
manager's policy.
 
Search WWH ::




Custom Search