Other Ways to Choose Colors

To use a color not included in the 13 constant variables, you must specify the color's sRGB or HSB values. sRGB, which stands for Standard Red Green Blue, defines a color by the amount of red, green, and blue that is present in the color. Each value ranges from 0, which means there is none of that color, to 255, which means the maximum amount of that color is present. Most graphics editing and drawing programs will identify a color's sRGB values.

If you know a color's sRGB values, you can use it to create a Color object. For example, an sRGB value for dark red is 235 red, 50 green, and 50 blue, and an sRGB value for light orange is 230 red, 220 green, and 0 blue. The following is an example of a panel that displays ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.