Java Reference
In-Depth Information
Answers to Review Questions
1.
GUI stands for graphical user interface, and it refers to the visual portion of your applica-
tion that a user sees and interacts with.
2.
AWT stands for Abstract Windowing Toolkit, and it refers to a collection of classes and
interfaces for developing GUI programs.
3.
Sorry to say, Swing is not an acronym, nor does it refer to anything. Swing is a collection of
GUI components and APIs that are more robust and versatile than the AWT. The story I
heard from Sun was that someone used the comment “That really swings” when first see-
ing Metal, the initial name given to the Swing project.
4.
Answer a is true because that is the definition of a heavyweight component. Answer b is
not true; the look and feel of a lightweight component is determined by the component,
which is why answer c is true. Answer d is also true, but answer f is not entirely true.
(Swing has several heavyweight components, including the windows such as JFrame and
JDialog.) Answer e is true.
5.
The initial size of Frame, JFrame, Dialog, and JDialog objects is 0 pixels high by 0 pixels wide.
6.
It will be 340 pixels wide by 280 pixels high. The 120 and 200 denote its location on the
screen, but do not affect the size of the JFrame.
7.
Not all AWT components are containers, only those that are child classes of java.awt.Con-
tainer, so the correct answer is d.
8.
You use one of the overloaded add() methods.
9.
FlowLayout.
10.
BorderLayout.
11.
Both have FlowLayout by default.
12.
Answer a is true; FlowLayout gives all components their preferred size. Answer b is false;
the east and west components get their preferred width, but the north and south compo-
nents do not. Instead, they get their preferred height, and the center component does not
get its preferred width or height. Answer c is true; components in GridLayout are all the
size of the regions in the grid, which are all the same size. Answer d is true; horizontal
components get their preferred width and vertical components get their preferred height.
Answer e is false; in fact, the exact opposite is true. The order components are added in
exactly the way they appear in the grid. Answer f is true; only five components can be
added to a container with BorderLayout. However, any one of those components can be a
container (like a Panel) that contains any number of components.
13.
True. A Panel can be assigned to any layout manager.
14.
True. Panels are often nested within other panels.
15.
The number of rows is defined as 0, which means that any arbitrary number of rows can
appear. Because the number of columns is one, the five components will appear vertically
in one column spanning five rows.
16.
The no-argument constructor of JDialog creates a modeless dialog window.
Search WWH ::




Custom Search