How do I place randomly placed and randomly colored circles inside a box?

How do I place randomly placed and randomly colored circles inside a box? I need to place 100 randomly colored and randomly placed circles inside a box about 400x300. Can somebody help?
[192 byte] By [StXdAa] at [2007-11-26 16:30:12]
# 1
Do you know how to generate random numbers?
CaptainMorgan08a at 2007-7-8 22:54:38 > top of Java-index,Java Essentials,Java Programming...
# 2
No I do not. Sorry, beginner here
StXdAa at 2007-7-8 22:54:38 > top of Java-index,Java Essentials,Java Programming...
# 3
Look into [url= http://java.sun.com/j2se/1.5.0/docs/api/java/util/Random.html]java.util.Random[/url].
CaptainMorgan08a at 2007-7-8 22:54:38 > top of Java-index,Java Essentials,Java Programming...
# 4

OK. I figured out how to place/color it randomly, but now I need to figure out how to put it all inside a box. It is randomly placed throughout the whole screen, and I don't really know how to box it in. Here's what I have now.

Random rndInt = new Random(1234);

for (int k = 1; k <= 100; k++)

{

int x = rndInt.nextInt(800);

int y = rndInt.nextInt(600);

int red = rndInt.nextInt(256);

int green = rndInt.nextInt(256);

int blue = rndInt.nextInt(256);

g.setColor(new Color(red,green,blue));

g.fillOval(x,y,50,50);

}

StXdAa at 2007-7-8 22:54:38 > top of Java-index,Java Essentials,Java Programming...
# 5
What are you displaying these on? A JPanel? If so, try something like this:int x = rndInt.nextInt(yourPanel.getWidth());int y = rndInt.nextInt(yourPanel.getHeight());
CaptainMorgan08a at 2007-7-8 22:54:38 > top of Java-index,Java Essentials,Java Programming...