FileDocCategorySizeDatePackage
YesNoDialog.javaAPI DocExample2643Sat Jun 02 03:11:18 BST 2001None

YesNoDialog

public class YesNoDialog extends Dialog

Fields Summary
public static final int
NO
public static final int
YES
public static final int
CANCEL
protected Button
yes
protected Button
no
protected Button
cancel
protected MultiLineLabel
label
Constructors Summary
public YesNoDialog(Frame parent, String title, String message, String yes_label, String no_label, String cancel_label)

    
          
                    
    
        // Create the window.
        super(parent, title, true);

        // Specify a LayoutManager for it
        this.setLayout(new BorderLayout(15, 15));
        
        // Put the message label in the middle of the window.
        label = new MultiLineLabel(message, 20, 20);
        this.add("Center", label);
        
        // Create a panel of buttons, center the row of buttons in
        // the panel, and put the pane at the bottom of the window.
        Panel p = new Panel();
        p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
        if (yes_label != null) p.add(yes = new Button(yes_label));
        if (no_label != null)  p.add(no = new Button(no_label));
        if (cancel_label != null) p.add(cancel = new Button(cancel_label));
        this.add("South", p);

        // Set the window to its preferred size.
        this.pack();
    
Methods Summary
public booleanaction(java.awt.Event e, java.lang.Object arg)

        if (e.target instanceof Button) {
            this.hide();
            this.dispose();
            if (e.target == yes) answer(YES);
            else if (e.target == no) answer(NO);
            else answer(CANCEL);
            return true;
        }
        else return false;
    
protected voidanswer(int answer)

        switch(answer) {
            case YES: yes(); break;
            case NO:  no(); break;
            case CANCEL: cancel(); break;
        }
    
protected voidcancel()

protected voidno()

protected voidyes()