import java.applet.*;
import java.awt.*;
import java.lang.*;
import java.util.*;


/*
    QuitDialog class - gives user a chance to confirm the exit
*/


class QuitDialog extends Frame
{
    /*
        PUBLIC METHODS
    */


    /*
        constructor method
    */

    public QuitDialog (Panel prnt)
    {
        //setBackground (new Color (150, 150, 150));

        setLayout(new BorderLayout());
        Panel topPanel = new Panel();
        topPanel.setLayout(new BorderLayout(0, 20));
        add("Center", topPanel);

        /* create and add to dialog labels */

        Label l = new Label ("Do you really want to quit?", Label.CENTER);
        l.setFont (new Font ("Helvetica", Font.BOLD, 12));
        topPanel.add ("Center", l);

        /* create and add to dialog a panel holding two buttons */

        Panel p = new Panel ();
        p.add (new Button ("OK"));
        p.add (new Button ("Cancel"));
        topPanel.add ("South", p);

        /* make sure dialog does not display until specifically told to */

        hide ();

    } /* end QuitDialog */


    public void paint (Graphics g)
    {
        //Rectangle bounds = bounds ();

        //g.setColor (getBackground ());
        //g.draw3DRect (0, 0, bounds.width - 1, bounds.height - 1, true);

    } /* end paint */


    public Insets insets()
    {
        return new Insets (30, 20, 30, 20);

    } /* end Insets */


    /*
        handle  events
    */

    public boolean handleEvent (Event e)
    {
    	String label;

        if (e.target instanceof Button)
        {
	        label = ((Button)(e.target)).getLabel();
	    }
	    else
	    {
	    	label = "null";
	    }

        // Scheint überflüssig zu sein.
        if (e.id == Event.WINDOW_ICONIFY) {
            System.out.println("Ikonifizieren");
            hide();
            return true;
        }
        if (e.id == Event.WINDOW_DESTROY) {
            System.out.println("Zerstören");
            // dispose();
            // Durch dispose() werden alle Datenstrukturen freigegeben,
            // deswegen erscheint das Fenster nachher in "Standard-Größe".
            // CLK
            hide();
            return true;
        }

        if (label.equals ("OK"))
        {
            /* perform system exit */
            System.out.println("Auf OK geklickt");
            System.exit (0);
            return true;
        }
        else if (label.equals ("Cancel"))
        {
            /* make dialog go away */
            System.out.println("Auf Cancel geklickt");
            hide ();
            return true;
        }
        else if (e.id == Event.MOUSE_DOWN)
        {
        	System.out.println("Daneben geklickt");
        	return true;
        }

        return false;

    } /* end handleEvent */

} /* end QuitDialog */

