
386 • Java Programming
14.12.4 Using Color
Java is designed to work with the RGB color system. An RGB color is specified by three numbers that give
the level of red, green and blue, respectively, in the color. A color in Java is an object of the class, Color .
A new color can be constructed by specifying its red, blue and green components. For example,
Color myColor = new Color(r, g, b);
There are two constructors that can be called in this way. In the one that is commonly used r , g and b are
integers in the range 0 to 255 . In the other, they are numbers of type float in the range 0.0F to 1.0F .
Often, constructing new colors can ...