//***************************************************************
//  Doodle.java       Authors: Lewis and Loftus
//                    Updated: Bary W Pollack
//
//  Demonstrates the use of GUI components.
//***************************************************************

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Doodle extends Applet implements ActionListener {

    //------------------------------------------------------------
    //  Creates the GUI components and adds them to the applet.
    //  The applet serves as the listener for the button.
    //------------------------------------------------------------
    public void init() {
        Label titleLabel = new Label("Doodle using the mouse.");
        titleLabel.setBackground(Color.cyan);
        add(titleLabel);

        canvas = new DoodleCanvas();
        add(canvas);

        Button clearButton = new Button("Clear");
        clearButton.addActionListener(this);
        add(clearButton);
        
        Label bottomLabel = new Label("Now, what happens if you "
                                      + "resize the applet?");
        bottomLabel.setBackground(Color.cyan);
        add(bottomLabel);

        setBackground(Color.cyan);
        setSize(APPLET_WIDTH, APPLET_HEIGHT);
    }

    //------------------------------------------------------------
    //  Clears the canvas when the clear button is pushed.
    //------------------------------------------------------------
    public void actionPerformed(ActionEvent event) {
        canvas.clear();
    }

    private final int APPLET_WIDTH  = 300;
    private final int APPLET_HEIGHT = 275;
    private DoodleCanvas canvas;
}
