// Lars Sorensen TYJava in 21 days // excode from pg 186, The Checkers animation // // SHELL FOR ANIMATION APPLETS // import java.awt.Graphics; import java.awt.Color; public class Checkers extends java.applet.Applet implements Runnable { Thread runner; int xpos, ux1, ux2; public void start() { if (runner == null ) { runner = new Thread(this); runner.start(); } } // end of start public void stop() { if (runner != null ) { runner.stop(); runner = null; } } // end of stop public void run() { setBackground(Color.blue); while(true) { for( xpos = 5; xpos <= 105; xpos +=4) { ux2 = xpos + 90; repaint(); try { Thread.sleep(100); } catch (InterruptedException e) { } if ( ux1 == 0 ) ux1 = xpos; } for( xpos = 105; xpos > 5; xpos -=4) { ux1 = xpos; repaint(); try { Thread.sleep(100); } catch (InterruptedException e) { } if ( ux2 == 0 ) ux2 = xpos + 90; } } } // end of run public void update(Graphics g) { g.clipRect(ux1, 5, ux2 - ux1, 95); paint(g); } // end of overriden update public void paint(Graphics g) { // draw the background g.setColor(Color.black); g.fillRect(0,0,100,100); g.setColor(Color.white); g.fillRect(101,0,100,100); // Draw the Checker.... g.setColor(Color.red); g.fillOval(xpos,5,90,90); // reset the drawing area ux1 = ux2 = 0; } // end of paint } // end of class Checkers...