I am a Java beginner, and I am trying to make a program in which white balls appear on the screen constantly. There should be a few seconds pause between one ball appearing before the next, and the balls need to appear at different places on the screen. I need help using the RandomGenerator to make the balls appear at different places. Any help would be greatly appreciated!
private RandomGenerator rgen = new RandomGenerator();
//~ Constructor ...........................................................
// ----------------------------------------------------------
/**
* Creates a new BubbleGame object.
*/
public void init()
{
//call method to create regions
CreateRegions();
//add mouse listeners
addMouseListeners();
//loop to add bubbles
while (true)
{
//create a filled bubble
GOval bubble = new GOval (100, 100, 50, 50);
bubble.setFilled(true);
bubble.setColor(Color.WHITE);
//randomly generate coordinates within the field
int rgen =
//add the bubble and pause
add(bubble);
Thread.sleep(3000);
}
}