Java Reference
In-Depth Information
DIAL-A-DIALOG
METHODS
DESCRIPTION
String title, int
messageType, Icon
icon)
You could have used one of these for the About dialog instead of all that messing about with inner classes.
Let's see how.
TRY IT OUT: An Easy About Dialog
Delete the AboutDialog inner class from SketcherFrame — you don't need that any longer. Change the
implementation of the actionPerformed() method in the SketcherFrame class to the following:
public void actionPerformed(ActionEvent e) {
if(e.getSource() == aboutItem) {
// Create about dialog with the app window as parent
JOptionPane.showMessageDialog(this,
//
Parent
"Sketcher Copyright Ivor Horton 2011", //
Message
"About Sketcher",
//
Title
JOptionPane.INFORMATION_MESSAGE);
//
Message type
}
}
Directory "Sketcher 3 with an easy About dialog"
If you recompile SketcherFrame and run Sketcher once more, you should get something like the window
shown in Figure 20-4 when you click the Help/About menu item.
FIGURE 20-4
 
 
Search WWH ::




Custom Search