
Working with AWT • 511
Explanation: In this program, the dialog box is called
and displayed on clicking a menu item. The class dialog
represents a dialog window. It is similar to classes seen
earlier. In the constructor of this dialog class, one label
and two buttons are added. When “OK” button is pressed
the dialog box will be disposed.
In the MyFrame class constructor a menu is
created. In the menu, just one menu item is added by
the name “Show Dialog”. When this menu item is
clicked, actionPerformed method will be called.
In the method an instance of dialog class is created and
displayed using setVisible method by passing argument ...