import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class Kukkumine4 extends Applet implements MouseListener, Runnable{ int x=100; double y=100; int alaServ=300; int r=5; double samm=1; double sammuMuutus=0.1; Color[] varvid={Color.green, Color.blue, Color.black, Color.pink}; int varviNr=0; public Kukkumine4(){ addMouseListener(this); new Thread(this).start(); } public void paint(Graphics g){ g.setColor(varvid[varviNr]); g.drawOval(x-r, (int)y-r, 2*r, 2*r); } public void run(){ while(true){ try{Thread.sleep(100);} catch(Exception viga){} if(y=varvid.length){varviNr=0;} } repaint(); } } public void mousePressed(MouseEvent e){ if(e.getX()>x-r && e.getX()y-r && e.getY()