GUI
Classwork
Part A
Set up a JFrame using NetBeans' editor.
Add a JSpinner, a JSlider, and a JButton.
Set the JSpinner's Model type to Number with min 0 and max 100, and start at 50.
Set the JSlider's min and max the same. Set the text on the button to
Reset.
In the GUI class, create an int instance variable currentVal which
starts at 50.
Add two JLabels, one with just the text, one showing currentVal's value.
To the JButton, add an actionPerformed method that sets the value of the
Spinner and the slider and currentVal all back to 50, and updates the
JLabel to match.
Whenever the spinner or slider changes value (StateChanged) update the
other's value and currentVal to match, and update the label.
Part
B
Set up a JFrame using NetBeans' editor.
In Homework 3B you created a class Taxpayer. Add any group
member's Taxpayer class to your project (you can download the zipped
project from Blackboard).
Using appropriate widgets (you may use ones not covered in the notes, if
you wish), set up a GUI allowing
the user to set age, marital status, veteran status, and income.
In JLabels, the user should see the amount of money they are paying tax on (that is,
after taking out exemptions), the amount of tax they pay, and their
remaining take-home income based on changes to the settings. In
Taxpayer, printTax() currently prints some of this information.
Change Taxpayer so that the information is returned so you can use it..
- lay out your GUI attractively and use extra JLabels so that each
widget is clearly marked
- any change to any widget should cause immediate updates (i.e.
user should not have to click a button after changing income to see
the new tax value)
- all calculations and storage of data should be done by a
Taxpayer object, not replicated in the GUI
- you may make changes to Taxpayer if necessary to provide methods
that make your life easier, but Taxpayer should not know about the
GUI.