/** This is the action listener method that the menu items invoke */ public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if (command.equals("quit")) { YesNoDialog d = new YesNoDialog( this, "Really Quit?", "Are you sure you want to quit?", "Yes", "No", null); d.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("yes")) System.exit(0); else textarea.append("Quit not confirmed\n"); } }); d.show(); } else if (command.equals("open")) { FileDialog d = new FileDialog(this, "Open File", FileDialog.LOAD); d.show(); // display the dialog and block until answered textarea.append("You selected file: " + d.getFile() + "\n"); d.dispose(); } else if (command.equals("about")) { InfoDialog d = new InfoDialog( this, "About", "This demo was written by David Flanagan\n" + "Copyright (c) 1997 O'Reilly & Associates"); d.show(); } }