Java Reference
In-Depth Information
The type pane is updated by calling the
setTypePane()
method for the status bar and passing the current
element type to it as an argument. You can add a similar statement to the
actionPerformed()
method
in the
ColorAction
inner class to update the color pane:
public void actionPerformed(ActionEvent e) {
elementColor = color;
setChecks(colorMenu, e.getSource());
statusBar.setColorPane(color);
}
Directory "Sketcher 1 with a status bar"
If you now recompile and run Sketcher again, you see the status bar in the application, as shown in
Figure
20-1
.
As you change the element type and color through the menus or toolbar buttons, the status bar is updated
automatically.
USING DIALOGS
A dialog is a window that is displayed within the context of another window — its parent. You use dialogs
to manage input that can't be handled conveniently through interaction with the view — selecting from a
range of options, for example, or enabling data to be entered from the keyboard. You can also use dialogs
for information messages or warnings. The
JDialog
class in the
javax.swing
package defines dialogs, and
a
JDialog
object is a specialized sort of
Window
. A
JDialog
object typically contains one or more com-