|
Random Generator
I need help with the thing to add to my code to make all the eclipses into circles and make them all random colors.
/*
Jordan Nissley
Boxes.java
*/
import java.applet.Applet;
import java.awt.*;
import java.util.Random;
public class Boxes extends Applet
{
//-----------------------------------------------------------------
// Paints boxes of random width and height in a random location.
// Narrow or short boxes are highlighted with a fill color.
//-----------------------------------------------------------------
public void paint(Graphics page)
{
final int NUM_BOXES = 100, THICKNESS = 5, MAX_SIDE = 50;
final int MAX_X = 350, MAX_Y = 250;
int x, y, width, height;
setBackground (Color.black);
Random generator = new Random();
for (int count = 0; count < NUM_BOXES; count++)
{
x = generator.nextInt (MAX_X) + 1;
y = generator.nextInt (MAX_Y) + 1;
width = generator.nextInt (MAX_SIDE) + 1;
height = generator.nextInt (MAX_SIDE) + 1;
page.setColor (Color.white);
page.drawOval (x, y, width, height);
}
}
}
__________________
~Live as if you were to die tomorrow.~
|