import java.util.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.text.*;

public class Clock1 extends Applet implements ActionListener {
	public void init() {
		setLayout(new FlowLayout(FlowLayout.CENTER));

		clock = new Label(simpleDateFormat.format(new Date(0)));
		add(clock);

		b = new Button("Start");
		add(b);
		b.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e) {
		paused = !paused;
		if (!paused) {
			b.setLabel("Pause");
			if (firstTime) {
				firstTime = false;
				startClock();
			}
		}
		else {
			b.setLabel("Resume");
		}
	}

	void startClock() {
		Date startDate = new Date();
		while (true) {
			if (!paused) {
				Date duration = new Date(new Date().getTime() - startDate.getTime());
				clock.setText(simpleDateFormat.format(duration));
			}
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
			}
		}
	}


	SimpleDateFormat simpleDateFormat = new SimpleDateFormat("mm:ss");
	boolean paused = true;
	Button b;
	Label clock;
	boolean firstTime = true;
}