|
|
What would GUI programming be without the ability to control colors? Naturally, Java provides support for this, via a class called As with any Java class, you can learn a lot from going to the The primary color model that you will tend to use is the RGB (Red, Green, Blue) model, although there are others. With the RGB model, every color is represented in terms of its red, green and blue components, each within a range of 0 through 255. 0 means no contribution from a given color component, while 255 means 100% contribution from a given color component. The class The above names can be used in a Java program to specify a particular color. For example: Color.MAGENTA Prior to JDK 1.4, the predefined colors were given only lowercase names: Color.magenta and you can still use the lowercase names if you wish. However, all new code should use the uppercase versions. Note that those (newer) names with an underscore have (older) lowercase equivalents in "bumpy case": Color.DARK_GRAY <-> Color.darkGrayColor.LIGHT_GRAY <-> Color.lightGray |
This page was last modified on 02 October, 2007 |