Getting More Colors:
You can fine tune your colors by controlling the RGB
(red/green/blue) density values. Each of these 3 colors has 256
shades. It is possible to "mix" a new shade of color by selecting an
integer from 0 to 255 and passing it to a Color constructor. The
value 0 indicates the absence of a color in the mixture, and the value 255
indicates the maximum saturation of that color. The color black has
RGB(0,0,0) and the color white has RGB(255,255,255).
There are 256 * 256 *256 = 224 possible
colors in this scheme.
To create your
Access the PAINT program on your
computer to help you decide upon your new color.
Paint - Double click on any
color at the bottom of the screen.
- Choose "Define Custom Colors".
- Select a color and/or use the arrows to achieve the
- Copy down the RED, GREEN, BLUE numbers indicated.
are the numbers needed to create your new Java color.
Create your new color by using the following code.
Replace the R, G and B with the numbers pertaining to your new color.
Color myNewBlue = new Color (R, G, B);
//creates your new color
g.setColor(myNewBlue); //accesses your
new color (NO dot operator)
Creating Random Colors:
Create a random color with RGB values: