i want to choose randomly colors, but only between of them (Red, Blue, Green and Yellow), here some of the code i'm trying.
public class LittleBall extends JPanel {
private Random random = new Random();
private float r = random.nextFloat();
private float g = random.nextFloat();
private float b = random.nextFloat();
.....
public void paint (Graphics g) {
Color randomColor = new Color(r, this.g, b);
g.setColor(randomColor);
}
}
But this just give every color in the world o.O, of course because the nextFloat of the r,g, and b variables is giving random numbers. But i just want to give go between colors.
Thanks.