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

class ClockFrame extends Frame implements ActionListener {
    // The labels for the buttons.
    static final String quitString = "Quit";

    public ClockFrame(){
        final int width = 200, height = 200;
        setSize(width,height);
        // Add the quit button ...
        addButton(quitString,"South");
        // ... and the drawing area.
        add(canvas,"Center");
        // Run the clock in its own thread.
        Thread t = new Thread(canvas);
        t.start();
    }

    // Work out which button was pressed.
    public void actionPerformed(ActionEvent e){
        String command = e.getActionCommand();

        if(command.equals(quitString)){
            System.exit(0);
        }
        else{
            System.err.println("Unknown command: "+e);
        }
        // Repaint the canvas in the current colour.
        canvas.repaint();
    }

    // Add a new button with label and command s.
    // Use the label as the associated command.
    private void addButton(String label, String where){
        Button b = new Button(label);
        b.addActionListener(this);
        b.setActionCommand(label);
        add(b,where);
    }

    // Where to draw the oval.
    private Clock canvas = new Clock();
}

