The Bouncy Applet

© Copyright 1998 University of New Haven

public class Bouncy extends java.applet.Applet
{
	final int top= 50,  bottom= 150;
	int i= top,  incr= 2;

	public void paint(java.awt.Graphics g)
	{
		if  (i < top  ||  i > bottom)  incr= -incr;
		i += incr;
		g.setColor(java.awt.Color.green);
		g.fillOval(10,i, 20,20);
		repaint(15, 10,top, 21,bottom);
	}
}
Home