FileDocCategorySizeDatePackage
YesNoDialog.javaAPI DocExample2081Tue Feb 27 14:23:26 GMT 2001None

YesNoDialog

public class YesNoDialog extends Dialog implements ActionListener
YesNoDialog - put up a Yes/No/Cancel dialog, with callbacks This version has three buttons, and a callback on each one.
deprecated
Use javax.swing.JOptionPane instead
author
Ian Darwin, Learning Tree.

Fields Summary
protected Frame
parent
protected Button
yB
protected Button
nB
protected Button
cB
protected Label
msgLab
Constructors Summary
public YesNoDialog(Frame parent, String title, String msg, String yesLab, String noLab, String canLab)
Constructor for a YesNoDialog.

param
parent Frame that is to own this dialog
param
title String to display in titlebar.
param
msg String to display in the dialog itself.
param
yesLab String for Yes button
param
noLab String for No button
param
canLab String for Cancel button

		super(parent, title, true);	// modal
		this.parent = parent;
		setLayout(new BorderLayout(10, 10));
		msgLab = new Label(msg, Label.CENTER);
		add("North", msgLab);

		Panel p = new Panel();
		p.setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));
		if (yesLab != null) {
			p.add(yB = new Button(yesLab));
			yB.addActionListener(this);
		}
		if (noLab != null) {
			p.add(nB = new Button(noLab));
			nB.addActionListener(this);
		}
		if (canLab != null) {
			p.add(cB = new Button(canLab));
			cB.addActionListener(this);
		}
		add("South",  p);
		pack();
	
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)
The action handler figures out which button was pressed, and calls the appropriate callback routine.

		Object obj = e.getSource();
		if (!(obj instanceof Button))
			return;
		if (obj == yB)
			yes();
		if (obj == nB)
			no();
		if (obj == cB)
			cancel();
		setVisible(false);
		dispose();
	
protected voidcancel()
The cancel method does nothing, we expect you will override it.

	
protected voidno()
The no method does nothing, we expect you will override it.

	
protected voidyes()
The yes method does nothing, we expect you will override it.