APS Excellence in Physics Education Award
November 2019
Science SPORE Prize
November 2011
The Open Source Physics Project is supported by NSF DUE-0442581.
Color Fuchsia in Java
post and replies
Return to the Color Fuchsia in Java thread
Login to post to this thread
Color Fuchsia in Java
April 23, 2015 4:03AM UTC
Fernando Silva Fernandes
10 Posts
In Java, defining x as an object: x=Color.FUCHSIA gives an error. How can such color be defined in Java? Thanks, Fernando Fernandes
Re: Color Fuchsia in Java -
Apr 23 6:07AM UTC
Francisco Esquembre
237 Posts
Hi, Try Color.MAGENTA. Another solution, which applies to all colors is this: Color myFuchsia = new Color(255, 0, 255); // Where the values of the Color(int r, int g, int b) constructor are the red, green and blue components of the color. These values are integers from 0 (no component) to 255 (full component). Paco
Re: Re: Color Fuchsia in Java -
Apr 25 3:44AM UTC
Fernando Silva Fernandes
10 Posts
Hi, Paco
Color.MAGENTA is OK. However, I want to define different shades of a color.
Color myFuchsia = new Color(255, 0, 255) at Initialization, followed by (x is an object):
x = Color.myFuchsia, gives compilation error
x ="myFuchsia", compilation OK, but gives red color.
I am certainly missing some point.
Fernando
Re: Re: Re: Color Fuchsia in Java -
Apr 25 4:26AM UTC
Francisco Esquembre
237 Posts
Fernando, x = myFuchsia; or x = Color.MAGENTA; is the right syntax. Paco