Java.awt.Color
1. Common sense of color
Any color is composed of three primary colors (RGB), Java support 224 for color, that is, the red-green-blue component value
Between 0-255 (8-bit representation)
Constants in the 2.Color class
Public final static Color black = new color (0,0,0);
Public final static Color bule = new color (0,0,255);
.
.
There are a number of such constants that we can call directly to the class name without having to instantiate it.
Constructors in 3.Color
Public Color (int r,int g,int b); Of course there are other methods of construction, and this is just one of the most common ones.
Example: Construct a Gray object: color Gray = new color (205,205,205);
4. Set Brush color syntax
First, get the brush: Graphics g = image.getgraphics ();//The image here is an object
Then set the brush color: G.setcolor (Color.Blue);
5. How to set the picture background through the graphics
You can first set the color of the brush, which is the background color you want to set: G.setcolor (color), then use the method G.fillrec (x,y,width,height), fill it, and fill it with the specified shape. and
The color is set to the top of the color, so there is a specified background of the graphic.
Introduction to the Java Color class