Java Reference
In-Depth Information
public class TNTButton extends Button {
public TNTButton() {
super ();
initialize();
}
private void initialize() {
this .setSize( new Dimension(50, 25));
this .setFont( new Font("Tahoma", Font. PLAIN , 14));}
}
Notice that the size and font properties are set as specified in step 5. The calculation in UsefulFrame (changed in
step 9) should look like the following:
eb.setLocation( this .getWidth() - 60, this .getHeight() - 35);
The getGrossBtn method in EnterEmpInfo should look like the following:
private Button getGrossBtn() {
if (grossBtn == null ) {
grossBtn = new TNTButton();
grossBtn.setLabel("Gross");
grossBtn.setLocation( new Point(177, 365));
grossBtn.addActionListener( this );}
return grossBtn;
}
Notice that the changes specified in step 7 were implemented in the source code. (I.e., GrossBtn is defined as a
new TNTButton and only the location, not the size, of GrossBtn is specified.)
The constructor in EnterEmpInfo should look like the following:
public EnterEmpInfo() {
super ();
initialize();
}
Note also the setExitButtonLocation statement that was added to the initialize method. The ExitButton class
should look like the following:
package c5;
import java.awt.Button;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
 
Search WWH ::




Custom Search