|
Day 9: Building a Swing Interface
Notes and Corrections
- Page 228: The example statement to create a message dialog box is
incorrect -- the
showMessageDialog() methods do not return a
String object or any other value. Here's a corrected example:
JOptionPane.showMessageDialog(null,
"An asteroid has destroyed the Earth.",
"Asteroid Destruction Alert",
JOptionPane.WARNING_MESSAGE);
- Page 241: To complete the first exercise, use an input dialog to set the
frame's title, not a message dialog.
Source Files
Reader Questions
- Q: In the Info application on pages 229-231, what does the
frame.pack() statement on line 63 do?
A: Every interface component has a preferred size, though this is
often disregarded by the layout manager used to arrange the component within
a container. Calling a frame or window's pack() method causes it to be
resized to fit the preferred size of the components that it contains. Because
the Info application does not set a size for the frame, calling pack()
sets it to an adequate size before the frame is displayed.
Activities
|