import java.awt.*;
import java.awt.event.*;

        // A panel containing a single Quit button to dispose
        // of the parent frame and exit the program.
class QuitPanel extends Panel {
    public QuitPanel(){
        this("Quit");
    }

    public QuitPanel(String s){
        setBackground(Color.white);
        Button quitButton = new Button(s);
        quitButton.setBackground(Color.white);
        quitButton.addActionListener(
            new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    Container parent = getParent();
                    if(parent instanceof Frame){
                        ((Frame) parent).dispose();
                    }
                    // Exiting will fail if running from an applet.
                    try{
                        System.exit(0);
                    }
                    catch(RuntimeException ex){
                    }
                }
            }
        );
        add(quitButton);
    }
}


