import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class pallike extends Applet implements ActionListener{ TextField tf1=new TextField("Vajuta enterit ja pall kukub",30); public pallike(){ add(tf1); tf1.addActionListener(this); } public void actionPerformed(ActionEvent e){ Graphics g=getGraphics(); int y=1; int x=22; double samm=1; for(;y<340; y=(int)(y+samm), samm=samm+0.5){ g.setColor(Color.red); g.fillOval(x, y, 50, 50); try{Thread.sleep(20);}catch(Exception ex){} g.setColor(Color.white); g.fillOval(x, y, 50, 50); } for(;y>150; y=(int)(y-samm)){ g.setColor(Color.red); g.fillOval(x, y, 50, 50); try{Thread.sleep(70);}catch(Exception ex){} g.setColor(Color.white); g.fillOval(x, y, 50, 50); } for(;y<335; y=(int)(y+samm)){ g.setColor(Color.red); g.fillOval(x, y, 50, 50); try{Thread.sleep(40);}catch(Exception ex){} g.setColor(Color.white); g.fillOval(x, y, 50, 50); } g.setColor(Color.red); g.fillOval(x, y, 50, 50); } public static void main(String argumendid[]){ Frame f=new Frame("Kukkuvad pallid!"); f.add(new pallike()); f.setSize(500, 500); f.setVisible(true); f.addWindowListener(new Raamikuular()); } } class Raamikuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } }