尽快就要了,高手请教下..
谢谢了
这个程序是我以前写的 你改成APPLET就行了
import java.util.*;
import java.awt.*;
import java.text.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;
class ClockPanel extends JPanel implements Runnable{
Thread th=null;
String today;
Date date=null;
GregorianCalendar cal=new GregorianCalendar();
SimpleDateFormat df=new SimpleDateFormat("yyyy MM dd HH:mm:ss");
public ClockPanel(){
th=new Thread(this);
th.start();
}
public void run(){
while(th!=null){
repaint();
try{
Thread.sleep(500);
}catch(InterruptedException e){}
}
}
public void paintComponent(Graphics g){
super.paintComponent(g);
date=new Date();
cal.setTime(date);
today=df.format(date);
g.drawString(today,80,80);
}
}
class ClockFrame extends JFrame{
public ClockFrame(){
Container con=getContentPane();
ClockPanel p=new ClockPanel();
setTitle("clock");
setSize(300,200);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
con.add(p);
}
}
public class MyClock{
public static void main(String args[]){
ClockFrame f=new ClockFrame();
f.setVisible(true);
}
}