Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Use the API documentation for the Java 2 Platform to answer the following questions.
- The
ClickMe
component usesColor.BLACK
when setting up its border. What other colors can you get by name like this?- How would you create a
Color
object to represent purple? (Hint: Purple is made up of equal parts of red and blue.)- Which
Graphics
method would you use to draw a filled square?- Which
Graphics
method would you use to draw text?
Use what you've learned from the preceding questions to make the following modifications to theCheck your answers.ClickMe
component.
Note: The point of these exercises is to encourage you to read code and to use the API documentation. We haven't yet given you any detailed information about how to write code, but you might be surprised at how much you can do.
- Modify
ClickMe
to draw a red square instead of a green spot.
- Modify
ClickMe
to display your name in purple instead of a green spot.
Remember, to compile and use the
ClickMe
component, you need the files,
ClickMe.java
, and
ClickMeApp.java
. You can run the program using the command
Spot.java
java ClickMeApp
.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.