接著上面的部分,下面是APPLET主程式部分:
public class MyClock extends Applet implements Runnable
{
static final int BACKGROUND=0; //背景圖片的序號,供數組使用
static final int LOGO=1; //LOGO圖片的序號,供數組使用
static final String JAVEX="bear"; //錶盤上顯示的文字
static final double MINSEC=0.104719755; //分針和秒針在錶盤上的刻度(60個)間的弧度
static final double HOUR=0.523598776; //時針在錶盤上的刻度(24個)間的弧度
Thread clockThread = null; //使用多線程機制,用另一個線程不斷顯示圖片
//提供的預設參數,如果HTML檔案裡面沒有給參數就使用
int width = 100;
int height = 100;
Color bgColor = new Color(0,0,0);
Color faceColor = new Color(0,0,0);
Color sweepColor = new Color(255,0,0);
Color minuteColor = new Color (192,192,192);
Color hourColor = new Color (255,255,255);
Color textColor = new Color (255,255,255);
Color caseColor = new Color (0,0,0);
Color trimColor = new Color (192,192,192);
String logoString=null;
Image images[] = new Image[2]; //背景和LOGO的圖片
boolean isPainted=false; //如果第一次載入時繪製背景及錶盤,其他時候重繪則只繪製指標
//時鐘圓心的位置
int x1,y1;
//最上面那個三角形的刻度圖形的座標
int xPoints[]=new int[3], yPoints[]=new int[3];