The completed applet is given below.
The only tricky thing is to get the details right for selecting the random integers you want.
// assume that the drawing area is 400 by 400 public class thousandCircles extends Applet { Circle circ = new Circle(); Random rand = new Random(); public void paint ( Graphics gr ) { circ.setRadius( 5 ); circ.setColor( Color.red ); int count = 1; while ( count <= 1000 ) { int x = Math.abs( rand.nextInt() )% 400; int y = Math.abs( rand.nextInt() )% 400; circ.setPosition( x, y ); circ.draw( gr ); count = count + 1; } } }
Here is what the applet draws: