Java Reference
In-Depth Information
If you now recompile and run Sketcher again, you'll see the status bar in the application.
As you change the element type and color, the status bar will be 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 instance, 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 will typically
contain one or more components for displaying information or allowing data to be entered, plus buttons
for selection of dialog options (including closing the dialog), so there's quite a bit of work involved in
putting one together. However, for many of the typical dialogs you will want to use, the JOptionPane
class provides an easy shortcut to creating dialogs. Below is a dialog that we'll create later in this chapter
using just one statement.
We'll use this dialog to provide a response to clicking on a Help/About menu item that we will add to
Sketcher in a moment. First though, we need to understand a little more about how dialogs work.
Search WWH ::




Custom Search