Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
You can find the information needed to answer these questions in the API documentation for theColor
class.
- Question: The ClickMe applet uses
Color.red
to set the drawing color to red. What other colors can you get by name like this?
Answer: black, blue, cyan, dark gray, gray, green, light gray, magenta, orange, pink, white, and yellow.
- Question: How would you specify other colors, like purple?
Answer: Construct aColor
object for the color you want. The easiest way to do this is to specify the RGB values for the color you want. For example, purple isColor(0.5, 0.0, 0.5)
.
To read explanations about the solutions and to run the resulting applets, see Getting Started.
- Exercise: Modify the applet to draw a green square instead of a red spot.
Answer: Look at our solution, contained in theClickMeGreen.java
source file.
- Exercise: Modify the applet to display your name in purple instead of a red spot.
Answer: Look at our solution, contained in theClickMePurple.java
source file.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.