Java Reference
In-Depth Information
13.
In the getGrossBtn method, add the following statement:
grossBtn.addActionListener( this );
This will tie the Gross button to the actionPerformed method.
We now need to change the actionPerformed method so that it reads the hourly pay rate and calculates the gross
pay for the employee by multiplying the hourly pay rate by 40 (the number of hours in a work week).
14.
In the actionPerformed method, add the following statement:
String empPayRate = empPRTF.getText();
Ok, that's plenty of coding, let's do a little testing.
Tutorial: Testing EnterEmpInfo
Before we try to do the calculation and display the result, let's prove that we are actually retrieving the text field information.
1.
In the actionPerformed method, add the following println statement (after the statement
entered in step 14 above) to prove that pay rate has been successfully placed in the
variable empPayRate:
System.out.println(empPayRate);
2.
Run EnterEmpInfo as a Java application.
The frame should look like Figure 5-7 . Dang! Even before we test, there is trouble. Notice that the city, state, zip
text field isn't big enough to display the information. Also, the Gross and Exit buttons are different sizes: we obviously
need to define some button standards.
Figure 5-7.
 
Search WWH ::




Custom Search