samedi 24 janvier 2015

Java newColor constructor randomized

I am having a problem making a new Color that will be random in Java. I get a syntax error saying that double, double, double is not how you define a new color. How would I accomplish this? Anyways, here is the code that is giving me the trouble.



double colorCode = (double) (Math.random());

double r = colorCode % 255;
double g = (colorCode*2) % 255;
double b = (colorCode+128) % 255;

page.setColor(new Color(r,g,b);




Aucun commentaire:

Enregistrer un commentaire