import java.util.*;
import java.awt.*;
import java.applet.*;
import java.text.*;
public class JdkClock extends Applet implements Runable{
  Thread timer=null;
  Image clockp,sings[],animal[];
  int s,m,h,hh;
  AudioClip ipAu,towerAu;
  boolean canPaint=true;
  boolean flag=false;
  boolean strike=true;
  int counter=0;
  int lasts;
  Image offscreen_buff=null;
  Graphics offg;
  int i,j,t=0;
  int timeout=166;
  String img_name[]={"t0","t3","t2","t1","t2","t3","t0","t4","t5","t6","t5","t4"};
  String gif_name[]={"1","2","3","4","5","6","7","8","9","10","11","12"};
  int lastxs=0,lastys=0,lastxm=0,lastym=0,lastxh=0,lastyh=0;
  Date dummy=new Date();
  GregorianCalendar cal=new GregorianCaleadar();
   SimpleDateFormat df=new SimpleDateFormat("yyyyMMddHH:mm:ss");
  String lastdate=df.format(dummy);
  Font F=new Font("TimesRoman",Font.PLAIN,14);
  Font S=new Font("宋体",Font.BOLD,90);
  Date dat=null;
  Color fgcol=color.black;
  Color fgcol2=color.blue;
  Color white=new Color(255,255,255);
 public void init(){
  ipAu=getAudioClip(getCodeBase(),"ip.au");
  towerAu=getAudioClip(getCodeBase,"TowerClock.au");
  offscreen_buf=creatImage(700,500);
  offg=offscreen_buf.getGrapics();
  simgs=new Image[12];
  animal=new Image[12];
  int xcenter,ycenter,s,m,h;
  xcenter=315;
  ycenter=112;
  s=(int)cal.get(Calendar.SECOND);
  m=(int)cal.get(Calendar.MIMUTE);
  h=(int)cal.get(calendar.HOUR_OF_DAY);
  if(h<4)
  h=h+24-4;
  else h=h-4;
  lastxs=(int)(Math.cos(s*3.14f/30-3.14f/2)*15+xcenter);
  lastys=(int)(Math.sin(s*3.14f/30-3.14f/2)*15+ycenter);
  lastxm=(int)(Math.cos(m*3.14f/30-3.14f/2)*13+xcenter);
  lastym=(int)(Math.sin(m*3.14f/30-3.14f/2)*13+ycenter);
  lastxh=(int)(Math.cos((h*30+m/2)*3.14f/180-3.14f/2)*9+xcenter);
  lastyh=(int)(Math.sin((h*30+m/2)*3.14f/180-3.14f/2)*9+ycenter);
  lasts=s;
  if(h<12)
    if(h!=11)hh=h+1;
    else hh=0;
  else
  if(h!=23)hh=h-12+1;
  else hh=0;
  MediaTracker mt=new MediaTracker(this);
  for(i=0;i<12;i++){
    simgs[i]=getImage(getCodeBase(),img_name[i]+".gif");
    mt.addImage(simgs[i],i);
    }
    clockp=getImage(getDocumentBase(),"clockp.gif");
    mt.addImage(clockp,i++);
    try{mt.waitForAU();}catch(InterruptedException e){};
     MediaTracker mt=new MediaTracker(this);
     for(j=0;j<12;j++){
     animal[j]=getImage(getCodeBase(),gif_name[j]+",gif");
     mt.addImage(animal[j],j);
     }
     try{mt.waitForAll();}catch(InterruptedException e){};
     }
     public void panit(Graphics g){
     int xh,yh,xm,ym,xs,ys,strike_times;
     int xcenter,ycenter;
     String today;
     Integer gif_number;
     g.setColor(white);
     g.fillRect(1,1,738,499);
     xcenter=315;
     ycenter=112;
     dat=new Date();
     cal.setTime(dat);
     s=(int)cal.get(Calendar.SECOND);
     m=(int)cal.get(Calendar.MIMUTE);
     h=(int)cal.get(calendar.HOUR_OF_DAY);
     today=df.format(dat);
     if(h<4)
  h=h+24-4;
  else h=h-4;
  lastxs=(int)(Math.cos(s*3.14f/30-3.14f/2)*15+xcenter);
  lastys=(int)(Math.sin(s*3.14f/30-3.14f/2)*15+ycenter);
  lastxm=(int)(Math.cos(m*3.14f/30-3.14f/2)*13+xcenter);
  lastym=(int)(Math.sin(m*3.14f/30-3.14f/2)*13+ycenter);
  lastxh=(int)(Math.cos((h*30+m/2)*3.14f/180-3.14f/2)*9+xcenter);
  lastyh=(int)(Math.sin((h*30+m/2)*3.14f/180-3.14f/2)*9+ycenter);
  for(int loop=0;loop<100;loop++)
   {int x=(int)(java.lang.Math.random()*740);
    int y=(int)(java.lang.Math.random()*500);
    int red=(int)(java.lang.Math.random()*255);
    int green=(int)(java.lang.Math.random()*255);
    int blue=(int)(java.lang.Math.random()*255);
    g.setColor(new Color(red,green,blue));
    if((red>70)&&(green>70)&&(blue>70));
    g.drawString("*",x,y);
    lastxs=xs;lastys=ys;
    lastxm=xm;lastym=ym;
    lastxh=xh;lastyh=yh;
    lastdate=today;
    if(h<12)hh=h;
    else hh=h-12;
    if(hh==0)strike_times=hh;
    if((s==0&&m==0)||flag){
      if(counter<strike_times){
      flag=true;
      if(lasts!=s){
      if(strike){
      counter++;
      towerAu.play();
      }
      if(strike)strike=false;
      else strike=true;
       }
      }
      else{counter=0;
      flag=false;
       }
      }else
      if(lasts!=s)
       ipAu.play();
       lasts=s;
       if(s<=20&&m==0)
       g.drawImage(animal[hh],390,105,this);
       if(canPaint){
       t+=1;
       if(t==12)t=0;}
       g.drawImage(Simgs[t],270,140,this);
       if(canPaint){
        t+=1;
       if(t==12)t=0;}
       g.drawImage(Simgs[t],270,140,this);
       swith(t);
       {case0:g.setColor(Color.black);break;
       case1:g.setColor(Color.magenta);break;
       case2:g.setColor(Color.blue);break;
       }
       g.setFont(s);
       g.drawString("大摆钟",115,380);
       for(int delay=0;delay<20000;delay++);
       g.setFont(F);
       g.drawImage(clockp,280,71,this);
       g.setColor(fgco12);
       g.setColor(getBackground());
       g.setColor(fgco12);
       g.drawString(today,275,420);
       g.drawLine(xcenter,ycenter,xs,ys);
       g.setColor(fgco);
       g.drawLine(xcenter,ycenter-1,xm,ym);
       g.drawLine(xcenter-1,ycenter,xm,ym);
       g.drawLine(xcenter,ycenter-1,xh,yh);
       g.drawLine(xcenter-1,ycenter,xh,yh);
       g.setColor(newColor(150,200,150));
       canPaint=false;
       dat=null;
       }
      public void start()
      {
       if(timer==null)
      {
      timer=new Thread(this);
      timer.start();
      }
      }
      public void stop(){
      timer.stop();
      timer=null;
      }
      public void run(){
      while(timer!=null){
      try{timer.sleep(timeout);}catch(
      InterruptedException e){}
      canPaint=true;
      repaint();
      }
      timer=null;
      }
      public void update(Graphics g){
      if (offscreen_buf==null){
      offscreen_buf=createImage(740,500);
      }
      offg.clipRect(1,1,739,499);
      paint(offg);
      g.drawImage(offsceen_buf,0,0,this);
      }
      }编译的话老是提示第173行public void start()非法的表达式开始,百思不得其解,我用的是jdk1_6_01