import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.util.Date; public class hiiremang extends Applet implements MouseListener{ long algaeg=new Date().getTime(); int x; int y; int Rx; int Ry; int raadius; int x_id[]; int y_id[]; int mitmes=0; int lugeja=0; double savi=0; double sec; public hiiremang(){ x_id = new int[61]; y_id = new int[61]; for(int h=0; h<61; h++){ x_id[h]=(int)(500*Math.random())+50; y_id[h]=(int)(500*Math.random())+50; } raadius=10; addMouseListener(this); } public void paint(Graphics g){ g.setColor(Color.black); savi=Math.sqrt((x_id[mitmes]+raadius-x)*(x_id[mitmes]+raadius-x)+(y_id[mitmes]+raadius-y)*(y_id[mitmes]+raadius-y)); if(savi<10){ if(lugeja<10){ mitmes=mitmes+1; } lugeja=lugeja+1; if(lugeja==10){ long loppaeg=new Date().getTime(); long vaheaeg=loppaeg-algaeg; sec=(vaheaeg/1000.0); if(sec<10){ lugeja=0; raadius=raadius-1; algaeg=new Date().getTime(); } System.out.println(sec); } } g.fillOval(x_id[mitmes],y_id[mitmes],2*raadius,2*raadius); } public void mousePressed(MouseEvent e){ if(mitmes==0){algaeg=new Date().getTime();} x=e.getX(); y=e.getY(); repaint(); } public void mouseReleased(MouseEvent e){} public void mouseExited(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseClicked(MouseEvent e){} public static void main(String argumendid[]){ Frame f=new Frame("Esimene"); f.setSize(600, 600); f.setBackground(Color.blue); f.add(new hiiremang()); f.setLocation(200, 100); f.setVisible(true); } }