APS Excellence in Physics Education Award
November 2019

Education Prize Logo
Science SPORE Prize
November 2011

NSF Logo
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
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


Replies to Color Fuchsia in Java

Re: Color Fuchsia in Java -
Francisco Esquembre
228 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 -
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 -
Francisco Esquembre
228 Posts

Fernando,

x = myFuchsia;

or

x = Color.MAGENTA;

is the right syntax.

Paco



OSP Projects:
Open Source Physics - EJS Modeling
Tracker
Physlet Physics
Physlet Quantum Physics
STP Book