import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class HiirPall1 extends Applet implements MouseListener{ double x, y, allserv=200, r=10; public HiirPall1(){ addMouseListener(this); } public void mousePressed(MouseEvent e){ x=e.getX(); y=e.getY(); double samm=0, sammumuutus=0.5; Graphics g=getGraphics(); while(true){ g.setColor(getForeground()); g.drawOval((int)(x-r), (int)(y-r), (int)(2*r), (int)(2*r)); try{Thread.sleep(100);}catch(Exception ex){} g.setColor(getBackground()); g.drawOval((int)(x-r), (int)(y-r), (int)(2*r), (int)(2*r)); y=y+samm; samm=samm+sammumuutus; if(y>allserv){ samm=-0.8*Math.abs(samm); } } } public void mouseReleased(MouseEvent e){} public void mouseClicked(MouseEvent e){} public void mouseEntered(MouseEvent e){} public void mouseExited(MouseEvent e){} public static void main(String[] arg){ Frame f=new Frame("Kukkuv pall"); f.add(new HiirPall1()); f.setSize(300, 300); f.setVisible(true); } }