11. 利用线程方法编写 JApplet 程序,实现在浏览器端实时动态显示本地系统时钟
//Programme Name Watch.java import java.applet.Applet;
import java.awt.*;
import java.text.DateFormat;
import java.util.*;
public class Watch extends Applet { public void paint(Graphics g){
Date d=new Date();
DateFormat ldf=DateFormat.getDateTimeInstance(DateFormat.LONG,DateFormat.LONG);
//System.out.println(" 现在系统时间是(long):"+ldf.format(d));
String time=ldf.format(d).toString();
g.drawString(time,100,100); try{
Thread.sleep(1000);
}catch (InterruptedException e){}
repaint();
}
<html>
<head>
<title>JavaAppletDemo</title> </head>
<body>
<applet code="Watch.class"width=300 height=200>
</applet> </body> </html>
I1 保存为Watch.html 文件