import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Pall extends Applet implements Runnable{ int x=100; int y=100; int suund=0; boolean liikumine=true; public void ring(){ Graphics ring=this.getGraphics(); ring.setColor(Color.white); ring.drawOval(x, y, 20, 20); if (ring!=null){ if (suund==0){ x++; y++; } if (suund==1){ x++; y--; } if (suund==2){ x--; y--; } if (suund==3){ x--; y++; } if (suund==0 && y==getSize().height-20){ suund=1; } if (suund==3 && y==getSize().height-20){ suund=2; } if (suund==1 && x==getSize().width-20){ suund=2; } if (suund==0 && x==getSize().width-20){ suund=3; } if (suund==2 && y==0){ suund=3; } if (suund==1 && y==0){ suund=0; } if (suund==3 && x==0){ suund=0; } if (suund==2 && x==0){ suund=1; } ring.setColor(Color.black); ring.drawOval(x, y, 20, 20); } } public void start(){ liikumine=true; new Thread(this).start(); } public void run(){ while (liikumine==true){ ring(); try{ Thread.sleep(10); } catch (Exception erind){} } } public void stop(){ liikumine=false; } public static void main(String argumendid[]){ Frame f=new Frame("Pall ekraanil EksamVersion by Ryblik"); f.setSize(500, 400); Pall k = new Pall(); f.add(k); f.setVisible(true); k.start(); f.addWindowListener(new Raami2kuular()); } } class Raami2kuular extends WindowAdapter{ public void windowClosing(WindowEvent e){ System.exit(0); } }