next up previous
Next: Ode to Joy Up: Programming assignment Previous: Read about applets

Change colors

1.
Check out the section of the book pertaining to the setColor method. (The reason I keep telling you to look in the book is that you should get in the habit of looking up methods you are not familiar with, at least the first time you use them).
2.
The book explains how to make your own colors by specifying RBG components. You can play around with that if you want, but you can make life easy by using the predefined colors. They are: black, blue, cyan, gray, dark gray, light gray, green, magenta, orange, pink, red, white and yellow. To set the current color to blue, for example:

     g.setColor (Color.blue);

3.
Use the setColor method to make each of the items you draw a different color (two text items, a rectangle and an oval).



Allen B. Downey
2/11/1998