import java.awt.*; import java.applet.*; public class comb extends Applet implements Runnable { int stuff[] = new int[1000]; int a,b,c,q,gap; boolean done, start=true; public boolean mouseDown (Event e, int x, int y) { if(!start) start=true; return true; } public void init(){ setBackground(Color.white); } public void start(){ Thread t = new Thread(this); t.start(); } public void paint(Graphics g){ for(a=0;a<100;a++){ g.setColor(Color.green); if(a==c-1) g.setColor(Color.blue); if(a==c+gap-1) g.setColor(Color.red); if(astuff[c+gap]){ q=stuff[c]; stuff[c]=stuff[c+gap]; stuff[c+gap]=q; done=false; } repaint(); try{Thread.sleep(10);} catch(InterruptedException e){} } gap=(int)(gap/1.3); if(gap==0) gap=1; if(gap==9 ^ gap==10) gap=11; } start=false; repaint(); try{Thread.sleep(10);} catch(InterruptedException e){} } } } }