[Back to Home Page]
Java Applet Samples... [NEXT]
Random drawing Circles.

Source code...
import java.awt.*;
import java.util.Random;
import java.applet.Applet;

public class Circles extends Applet {
    public void paint(Graphics g) {
	Random a = new Random();
	for (int i = 0; i < 20; i++) {
	    g.setColor(new Color(a.nextInt()));
	    int x = (int)(300 * a.nextDouble());
	    int y = (int)(200 * a.nextDouble());
	    int r = (int)(40 * a.nextDouble()) + 10;
	    g.fillOval(x - r, y - r,2*r,2*r);
	}
    }
}