import java.awt.*; import java.applet.*; import java.util.*; public class kellake extends Applet implements Runnable { public kellake() { new Thread(this).start(); } public void joonista() { Graphics p=getGraphics(); if (p==null){return;} Image pilt=createImage(getWidth(),getHeight()); Graphics g = pilt.getGraphics(); if (g==null){return;} int h= new Date().getHours(); int m= new Date().getMinutes(); int s= new Date().getSeconds(); int keskx=getWidth()/2; int kesky=getHeight()/2; int raadius=100; g.setColor(Color.black); g.drawString("--3",keskx+raadius+3,kesky+5); g.drawString("9--",keskx-(raadius+17),kesky+5); g.drawString("|",keskx,kesky-(raadius+2)); g.drawString("12",keskx-5,kesky-(raadius+10)); g.drawString("|",keskx,kesky+raadius+10); g.drawString("6",keskx-2,kesky+raadius+21); g.setColor(Color.white); g.fillRect(keskx-20,kesky+raadius+23,50,50); g.fillOval(keskx-raadius,kesky-raadius,2*raadius-1,2*raadius-1); g.setColor(Color.black); g.drawString(h+":"+m+":"+s,keskx-20,kesky+raadius+35); g.drawOval(keskx-raadius,kesky-raadius,2*raadius,2*raadius); g.setColor(Color.blue); g.drawLine(keskx,kesky,(int)(keskx+(raadius-2)*Math.cos((h*30-90)*Math.PI/180)),(int)(kesky+(raadius-2)*Math.sin((h*30-90)*Math.PI/180))); g.setColor(Color.green); g.drawLine(keskx,kesky,(int)(keskx+(raadius-2)*Math.cos((m*6-90)*Math.PI/180)), (int)(kesky+(raadius-2)*Math.sin((m*6-90)*Math.PI/180))); g.setColor(Color.red); g.drawLine(keskx,kesky,(int)(keskx+(raadius-2)*Math.cos((s*6-90)*Math.PI/180)), (int)(kesky+(raadius-2)*Math.sin((s*6-90)*Math.PI/180))); p.drawImage(pilt,0,0,this); } public void run() { while (3>2){ try{Thread.sleep(50);}catch(Exception exs){} joonista(); } } public static void main(String arg[]) { Frame f=new Frame("KELL"); f.add(new kellake()); f.setSize(300,310); f.setVisible(true); f.addWindowListener(new Raamikuular()); } }