Basic HTML version of Foils prepared Sept 21 1998

Foil 56 Dialog Boxes

From Java Tutorial 98- 3: Graphics and the Abstract Windowing Toolkit NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

API for class Dialog
Another type of separate window is the Dialog box, which is not so elaborate as a frame.
  • Dialog(Frame, String Title, boolean mustbeansweredatonceornot);
  • // defines a dialog box
Dialog boxes are used for transient data
  • Issue warning to user or require (third argument true) user to verify some action etc. - e.g. this dialog box has warning text and an ok button:
    • class WarningDialog extends Dialog
    • { public WarningDialog(Frame parent)
    • {super(parent, "Dialog Box Label", true); //modal requires immediate
    • add(new Label("Read this stern Warning!"));
    • Button b = new Button("OK"));
    • b.addActionListener(this); add(b);
    • setSize(200,100); }
    • public void actionPerformed(ActionEvent e)
    • {if (e.getActionCommand().equals("OK")) dispose();
    • }
    • }



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998