日期:2014-05-20  浏览次数:20837 次

时钟的问题
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);