ASSIGNMENT #2: Circles
Score: 10 points
Bonus: 2 points (see below)
Due date: 2/10/06
I hope you remember the wonderful circle program, demonstrated in class on Wednesday. If not, here's a
picture that should give you the idea:
Simply beautiful. Your task this time: Make it even more impressive !
You will get the source code of the original program. Compile it, run it, make sure everything's fine.
Play around with it, so you get an idea what's happening. Your score so far: 0 points. The real task
description is here (the description order is not necessarily the order you should work on the assignment,
please read the full description first and make sure you understood):
- Change the frame in a way that it only shows a single circle + button (that's simple)
- The button should not switch the circle on/off, but toggle its color between... whatever 2 colors you want.
- Show 10 of these frames (each containing a single circle and its button). Make them simply single, independent
frames, not to be put together in any layout of a container frame.
- Create a window, containing a slider (class JSlider) and a button
- The slider should control the size of all circles, the button should switch on/off all circles
If you want 2 Bonus points, here comes the extended version !
- Let the extra window not only contain 1 slider + 1 button, but 1 slider + 5 buttons
- Button 1 toggles all circles, Button 2 toggles circles 2,4,6,8,10, Button 3 toggles circles 3,6,9,
Button 4 toggles ... guess what.
The source code is HERE !
Some hints:
- The control window, i.e. the frame containing the buttons and the slider, is a good place for the main
program.
- The ActionEvent, passed to the actionListener, contains information about the source.
A good place to look at is getActionCommand() in the class ActionEvent().
Please attend Aubrey's class tomorrow, thursday, Feb 2nd, at 2:30. You meet in front of the labs.
For questions feel free to mail to Aubrey, the TA or me, or just come to my office (308, Wachman Hall).
Good luck and have fun !