// Digitaluhr
// zeigt die Zeit, soll den Rechner nur gering belasten
// aus Java in 21 days, Tag 10
// <applet code=DigitalUhr.class width = 500 height=200> </applet>

import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
import java.util.Date;

public class DigitalUhr extends java.applet.Applet implements Runnable
{
Font meinFont = new Font("serif", Font.BOLD, 24);
Date meinDatum;
Thread meinProzess = null;

public void init()
{
setBackground(Color.yellow);
}

public void start()
{
if (meinProzess == null) 
	meinProzess = new Thread (this);
meinProzess.start();
}

public void stop()
{
if (meinProzess != null)
	meinProzess = null;
}

public void run()
{
Thread momentanerProzess = Thread.currentThread();
while (meinProzess == momentanerProzess)
      {
	repaint();
	try
	  {
	  Thread.sleep(1000);
	  }
	catch (InterruptedException e)
	  {
	  }
      }
}

public void paint(Graphics g)
{
meinDatum = new Date();
g.setFont(meinFont);
g.drawString(" " + meinDatum.toString(), 10,50);
}

}