import java.applet.Applet; import java.awt.*; import java.awt.event.ActionListener; import java.util.Calendar; import java.util.Date; import java.util.StringTokenizer; import javax.sound.sampled.*; public class kell2 extends Applet implements Runnable{ int sekundiosuti, minutiosuti, tunniosuti, minstart, mincheck,tund,minutid; Panel pan; TextField tf1=new TextField(); public void start() { gettime(); setLayout(new BorderLayout()); pan = new Panel(); add("Center",pan); add("South",tf1); Thread th= new Thread(this); th.start(); } public void run(){ //System.out.println(sekundiosuti); while (true) { //System.out.println(sekundiosuti); try{ Thread.sleep(1000); sekundiosuti+=6; clock(); } catch(InterruptedException e){} // System.out.println(sekundiosuti); // System.out.println(minutiosuti); // System.out.println(tunniosuti); if((sekundiosuti) % 360 == 0) { mincheck++; if(mincheck % 2==0){ tunniosuti -=5; }else{ tunniosuti -=6;} } else minutiosuti -=6;} } public void clock(){ int loendur; tund=0;minutid=0;loendur=0; Graphics g = pan.getGraphics(); //System.out.println(tf1.getText()); if(tf1.getText()!=""){ String temp=tf1.getText(); StringTokenizer st=new StringTokenizer(temp, ":"); while(st.hasMoreTokens()){ //String sona=st.nextToken(); int temparv=Integer.parseInt(st.nextToken()); System.out.println(temparv); if(loendur==0){ tund=temparv; loendur++; //System.out.println(loendur); //System.out.println(Calendar.getInstance().get(Calendar.HOUR)); }else{ minutid=temparv; //System.out.println(Calendar.getInstance().get(Calendar.MINUTE)); } } if((tund==Calendar.getInstance().get(Calendar.HOUR)) && (minutid==Calendar.getInstance().get(Calendar.MINUTE))){ g.setColor(Color.black); g.drawString("äratus",15,15); piiks(); } } //g.drawString("äratus",15,15); g.setColor(Color.gray); g.setColor(new Color(160,150,170)); g.drawString("1",138,30); g.drawString("2",170,60); g.drawString("3",180,105); g.drawString("4",168,148); g.drawString("5",139,180); g.drawString("6",96,190); g.drawString("7",52,180); g.drawString("8",23,145); g.drawString("9",14,105); g.drawString("10",18,60); g.drawString("11",51,30); g.drawString("12",93,20); g.setColor(Color.green); g.fillOval(25,25,150,149); Graphics2D g2 = (Graphics2D) g; g2.setColor(Color.green); //g2.fillOval(30,30,140,140); g2.setColor(Color.gray); g2.drawOval(98,98,4,4); int kx = 100; int ky = 100; g2.rotate (Math.toRadians(sekundiosuti),kx,ky); g2.drawLine(100, 100, 100, 40); g2.rotate (Math.toRadians(minutiosuti),kx,ky); g2.drawLine(100, 100, 100, 50); g2.rotate (Math.toRadians(tunniosuti),kx,ky); g2.drawLine(100, 100, 100, 60); } public void piiks(){ try { int kandesagedus =1000; byte[] andmed=new byte[5*kandesagedus]; //5 sekundit for(int i=0; i