//Motion.java import java.awt.*; import javax.swing.*; public class Motion extends JApplet { int moves, movesize, size, killtime; public void init() { String input; input = JOptionPane.showInputDialog( "Enter number of moves" ); moves = Integer.parseInt( input ); input = JOptionPane.showInputDialog( "Enter size of circle" ); size = Integer.parseInt( input ); input = JOptionPane.showInputDialog( "Enter distance of random move" ); movesize = Integer.parseInt( input ); input = JOptionPane.showInputDialog( "Enter count of time-killing loop" ); killtime = Integer.parseInt( input ); } public void paint (Graphics g) { int x=getWidth()/2; //start in center of applet int y=getHeight()/2; int xd, yd; for (int i=1; i<=moves; i++) { //"erase" current circle g.setColor(Color.WHITE); g.fillOval(x,y,size,size); //randomly: -1, 0, or 1 xd = (int)(Math.random()*3) - 1; yd = (int)(Math.random()*3) - 1; //add -movesize, 0, or +movesize to coordinates x = x + xd*movesize; y = y + yd*movesize; //draw circle at new position g.setColor(Color.RED); g.fillOval(x,y,size,size); //slow it down... for (int j=1; j