function:RenderSidePart pageleftbodycaption pageleftbody sidenote Main.PictureLabActivity2-SideNote Main.SideNote Site.SideNote

# Picking a Color

Run the main method in ColorChooser.java. This will pop up a window (Figure 2) asking you to pick a color. Click on the RGB tab and move the sliders to make different colors.

When you click the OK button, the red, green, and blue values for the color you picked will be displayed as shown below. The Color class has a toString method that displays the class name followed by the red, green, and blue values. The toString method is automatically called when you print an object.

java.awt.Color[r=139,g=174,b=255]

Java represents color using the java.awt.Color class. This is the full name for the Color class, which includes the package name of java.awt followed by a period and then the class name Color. Java groups related classes into packages. The awt stands for Abstract Windowing Toolkit, which is the package that contains the original Graphical User Interface (GUI) classes developed for Java. You can use just the short name for a class, like Color, as long as you include an import statement at the beginning of a class source file, as shown below. The Picture class contains the following import statement.

import java.awt.Color;

Use the ColorChooser class (run the main method) to answer the following questions.

# Questions

1. How can you make pink?
2. How can you make yellow?
3. How can you make purple?
4. How can you make white?
5. How can you make dark gray?