Color

Color is a class in the AWT. Individual colors like red or mauve are instances of this class, java.awt.Color. Be sure to import it if you want to use other than the default colors. You create new colors using the same RGB triples that you use to set background colors on web pages. However you use decimal numbers instead of the hex values used by HTML's bgcolor attribute. For example medium gray is Color(127, 127, 127). Pure white is Color(255, 255, 255). Pure red is (255, 0, 0) and so on. As with any variable you should give your colors descriptive names. For instance

Color medGray = new Color(127, 127, 127);
Color cream = new Color(255, 231, 187);
Color lightGreen = new Color(0, 55, 0);

A few of the most common colors are available by name. These are


Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified June 15, 1998