The java.awt.Color Class

The java.awt.Color class offers three services:

  1. static convenience methods

  2. instance methods

  3. color constants

The static convenience methods mostly involve constructing a Color from a String. Instance methods provide access to the color's rgb makeup, return darker or brighter shades of a color, perform an equality test, etc. The color constants are final static Colors that are used to represent commonly used colors and are listed below.

Color.black

Color.blue

Color.cyan

Color.darkGray

Color.gray

Color.green

Color.lightGray

Color.magenta

Color.orange

Color.pink

Color.red

Color.white

Color.yellow

Most use of the Color class involves accessing the constants listed above. Colors can be constructed, if need be, by one of seven ...

Get Graphic Java™ 1.2, Volume I: AWT, Third 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.