Graphic Java

The student probably realized while doing the last activity that there must be a way in Java to create custom colors. Well, that's what this activity is about. The Color class has a number of constructors. Here are two:

  Color(int r, int g, int b);
  Color(int r, int g, int b, int alpha);
It is no accident that the variables were named r, g, and b in the examples. These constructors allow the programmer to use the RGB color model to create a custom color. The R stands for red, the G stands for green, and the B stands for blue. Here are some colors, their corresponding RGB values, and constructors for each.
ColorRGB valuesConstructor
red255, 0, 0new Color(255,0,0);
yellow255, 255, 0new Color(255,255,0);
dark blue0,0,175new Color(0,0,175);

Basically, each parameter can be given a value of 0 to 255.

At this point the student should be asking, "What about the alpha value?" This corresponds to the transparency of the color. It can also have a value of 0 to 255.
EXAMPLE: The student will create an applet like the one shown here. The only difference is that the student will add one more square in the middle. This activity provides the student with practice creating custom colors.
x

ASSIGNMENT:
Recreate the applet shown above. The student may not use any pre-defined colors in this activity.