![]() ![]() |
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Answers to Questions
- 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:Color.black
,Color.blue
,Color.cyan
,Color.darkGray
,Color.gray
,Color.green
,Color.lightGray
,Color.magenta
,Color.orange
,Color.pink
,Color.white
, andColor.yellow
- Question: How would you specify other colors, like purple?
Answer: You specify them using the RGB (red-green-blue) color model. In RGB, purple is: 0.5, 0.0, 0.5Answers to Exercises
To read explanations about the solutions and to run the resulting applets, see Run the ClickMe Applets.
- 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.
Answers to Extra Credit Exercises
To read explanations about the solutions and to run the resulting applets, see Run the ClickMe Applets.
- Exercise: Modify the applet to erase the red spot instead of redrawing the whole applet.
Answer: Look at our solution, contained in theClickMeErase.java
source file.
- Exercise: Modify the applet to drag the red spot when the mouse is held down.
Answer: Look at our solution, contained in theClickMeDrag.java
source file.
- Exercise: Starting with your solution to the previous exercise, change the applet into a "scribble" applet, which draws as the mouse is dragged.
Answer: Look at our solution, contained in theClickMeScribble.java
source file.
![]() ![]() |
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |