You will do this exercise by yourself, but be quick to ask questions of your instructor, student assistants and classmates as desired.
GoalsThis exercise will let you:
|
Grading rubricYou start with 100 points. For each stage that is missing or implemented incorrectly, you lose 10 points.
Because this is an exploratory exercise, no documentation is required. |
You will implement this project in stages, testing at each stage to see if the project works correctly through that stage.
|
|
|
Test your understanding: Answer these questions to yourself, but be quick to discuss them with your instructor, a student assistant or a classmate if you are unsure of your answer.
|
|
To get a component to appear, you need to construct it, then add it to the component on which it is to appear. So:
|
|
|
Test your understanding:
|
|
|
|
Test your understanding:
|
|
|
|
Test your understanding:
|
|
You don't usually paint within a frame, instead you usually paint inside a panel that the frame contains. This is done using the paintComponent method. So:
|
|
|
|
|
For this, you will add an ActionListener:
Example 1: a panel responds to a button's clicks by having code like this in the panel's constructor:
Example 2: A button responds to its own mouse clicks by having code like this in the button's constructor:
Rule of thumb: A button should respond to its own button presses. Following that rule of thumb:
You will probably have questions in doing the above; ask away (instructor, student assistants or classmates) — it's OK! |
|
|
Test your understanding:
|
|
|
|
Test your understanding:
|
|
In this state, you will implement a crude form of animation — repeatedly pressing the third button moves the circle.
|
|
|
Test your understanding:
|
|
For this, you will add an MouseListener:
|
|
|
Test your understanding:
|
|
You have seen two ways to display data on the screen:
Two other ways to display data on the screen are:
|
|
|
Test your understanding:
|
|
You have seen that you can get input from the user via button-presses and mouse clicks. Two other ways to get input from the user are:
|
|
|
Test your understanding:
|
|
|
In your forthcoming projects you will want to learn more about Swing. The following tutorials from the Java Tutorials are excellent:
|
Test your understanding: You should now be comfortable with the following:
If you have questions about ANY of the above, bring your questions to class! |
Commit your project to your individual repository when you are done.