CSCI 161: Introduction to Programming I
Spring 2007
Extra Credit: Paycheck GUI

Due Thursday, April 19th at beginning of lab period


Overview

Here’s where your hard work on the Paycheck class pays off!  For this extra credit assignment, you will develop a graphical interface to your Paycheck class.

 

You should write a PaycheckPanel class, which will take in all of the information corresponding to the attributes of the Paycheck class.  You will also need to create a driver class called PaycheckGUI, whose main method instantiates a frame and a PaycheckPanel and displays the graphical interface.

 

This project requires three Java source files: Paycheck.java (you’ve already written this one), PaycheckPanel.java and PaycheckGUI.java.

 

Input Specification

Your interface might look something like this:

 

You must use JTextFields for the employee name, hourly rate, hours worked, and tax rate, JRadioButtons for the employee type, and a JCheckBox for the occupation tax.  Use JLabels to label all text fields, and to display the gross and net pay. 

 

Output Specification

When the user presses the “Calculate” button, you should call the computeGross and computeNet methods and display those values.  The values should be formatted as currency before being displayed, as shown below:

 

 

 

Hints

Listing 5.23 demonstrates a JCheckBox, and Listing 5.25 demonstrates a JRadioButton.

 

You only need one Listener class and one actionPerformed method.  In the actionPerformed method, you can test the source of the event – it could be one of the JRadioButtons or the JButton.