This program draws a bunch of basketballs on the screen so that we can watch them bounce randomly. Each click adds a ball to the display. Leaving the canvas makes the balls temporarily vanish. Moving the mouse back into the canvas makes the balls reappear and bounce for a while. It demonstrates the use of an array to keep track of a variable number of objects.
Click below to download the source files for GrowableBallBouncer.