YesNoDialogpublic class YesNoDialog extends Dialog implements ActionListenerYesNoDialog - put up a Yes/No/Cancel dialog, with callbacks
This version has three buttons, and a callback on each one. |
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.
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 void | actionPerformed(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 void | cancel()The cancel method does nothing, we expect you will override it.
| protected void | no()The no method does nothing, we expect you will override it.
| protected void | yes()The yes method does nothing, we expect you will override it.
|
|