import java.util.*;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.text.*;

public class Clock2 extends Applet implements ActionListener {
	public void init() {
		Diag.threadPrint("init");

		setLayout(new FlowLayout(FlowLayout.CENTER));
		Label clock = new Label(simpleDateFormat.format(new Date(0)));
		add(clock);

		b = new Button("Pause");
		b.setForeground(Color.red);
		add(b);
		b.addActionListener(this);

		clockThread = new Clock2Thread(clock);
		clockThread.start();
	}

	public void actionPerformed(ActionEvent e) {
		Diag.threadPrint("actionPerformed");
		boolean paused = clockThread.togglePaused();
		if (!paused) {
			b.setForeground(Color.red);
			b.setLabel("Pause");
		}
		else {
			b.setForeground(DARK_GREEN);
			b.setLabel("Resume");
		}
	}


	SimpleDateFormat simpleDateFormat = new SimpleDateFormat("mm:ss");
	static final Color DARK_GREEN = new Color(0, 100, 0);
	Button b;
	Clock2Thread clockThread;
}

	