        // Run a simple clock.
import java.applet.*;
import java.awt.*;

public class ClockApplet extends Applet {
    public void init(){
        Clock clock = getClock();
        // Give the clock a size.
        final Dimension size = getSize();
        clock.setSize(size.width,size.height);
        // Add it the drawing area.
        add(clock);
        // Start and suspend the clock's thread.
        // It will be (re)started properly by the start method.
        clock.setAnimationRunning(false);
        new Thread(clock).start();
    }

        // (Re)start the clock ticking.
    public void start(){
        getClock().setAnimationRunning(true);
    }

        // Suspend the clock from ticking so that it does not
        // consume any resources.
    public void stop(){
        getClock().setAnimationRunning(false);
    }

    protected Clock getClock(){
        return clock;
    }

    // The analogue clock to be run in its own thread.
    private final Clock clock = new Clock();
    {
        clock.setBackground(Color.white);
    }
}
