//Animate.java //Robert J. Russell import java.awt.*; import java.applet.*; public class Animate extends Applet { public void init() { } public void sleep(int ms) { try { Thread.sleep(ms); } catch (Exception e) { } } public void paint(Graphics g) { g.drawString("Stupid example of Animation -- a moving Oval!", 50, 60 ); //Repeat for (int i=70; i<200; i++) { g.setColor(Color.blue); //blue oval //Draw an oval (in varying positions) g.drawOval(i*2, i, 40, 20); //wait 20 ms; then erase it sleep(20); if (i<199) { //but don't erase the last one g.setColor(Color.white); //overwrite old oval with white, g.drawOval(i*2, i, 40, 20); //erasing it } } } }