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 rubricFor the first 6 stages, you receive 10 points if you implement that stage correctly. Each of the remaining stages is worth 20 points if implemented correctly. 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 can't paint within a frame, you need to paint inside a panel. 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:
Example 2: A button responds to its own mouse clicks:
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:
|
|
In your forthcoming projects you will want to learn more about Swing. The following tutorials from the Java Tutorials are excellent:
Commit your project to your individual repository when you are done.