Mega Code Archive

 
Categories / Java Tutorial / 2D Graphics
 

Java awt Color

A Color object represents a color. Color class provides static fields that return a specific Color object: BLACK, BLUE, GREEN, RED, CYAN, ORANGE, YELLOW. For example, to obtain a Color object that represents green, use this code: Color color = Color.GREEN; Create a custom color by passing red-green-blue (RGB) values to the Color class's constructor: Color myColor = new Color (246, 27, 27); To change a component's color, call the setForeGround and setBackGround methods of the component. component.setForeGround (Color.YELLOW); component.setBackGround (Color.RED);