//Clock.java 代码如下:
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.applet.*;
public class Clock extends Applet implements Runnable
{
Thread ClockThread;
public void start()
{ if(ClockThread==null)
{ ClockThread=new Thread(this,"Clock");
ClockThread.start();
}
}
public void run()
{ while(ClockThread!=null)
{ repaint();
try
{ ClockThread.sleep(1000);}
catch(InterruptedException e)
{}
}
}
public void paint(Graphics g)
{ Date now=new Date();
SimpleDateFormat format1=new SimpleDateFormat("yyyy年MM月dd日 E HH:mm:ss");
String w1=format1.format(now);
g.drawString(w1,35,100); }
}
//Clock.html 代码如下:
// 汪学明 2010-11-15 st_xmwang@163.com