Java Reference
In-Depth Information
10. If needed, drag the Customize Layout window out of the upper-left-hand corner of the
screen, so that the Menu bar Edit option is shown.
11. Click Edit , and then Undo Typing .
The labels will be returned to their previous locations. (By the way, don't forget about Undo while working
through the Tutorials. If you make a mistake on a step or several steps, simply keep selecting Undo until you are back
in sync with the Tutorial.)
12.
In the Customize Layout window, click the Show distribute box button (first row,
fourth column).
This selects the current area occupied by the selected components as the area of distribution. The area of
distribution can be changed by clicking and dragging the blue resize handles. In this case, we want to keep this
default area, so we will not make any adjustments.
13.
Click on Distribute vertically button (third row, fourth column) again.
This time, the labels are evenly spread over the originally defined area.
14.
Close the Customize Layout window.
15. Click on the white area outside the frame to deselect all components.
We need to give the new labels meaningful names. VE provides a very easy way to rename components.
16.
Right-click on the second label and select “Rename field” from the shortcut menu.
17.
Specify streetLbl as the new name and click the OK button.
Displaying the source code would show that the label has been renamed throughout the class. (By the way,
this is much easier than using the Find/Replace function in the source code.)
18.
Change the bottom label's name to cSZLbl and save EmployeeFrame.
Tutorial: Finishing the Application
VE's GUI can only do so much. Eventually programmers have to work directly with the source code.
In EmployeeFrame, we have to change the constructor to accept an Employee variable. In addition, we have to:
1.
Create a class level Employee variable
2.
Assign the method Employee variable to the class Employee variable
3.
Add code to move the Employee object's information to the labels
4.
Make the frame visible
5.
Fix the location of the Exit button
6.
Change EmployeeApp to create an EmployeeFrame object (instead of EmpFrame)
7.
Display the source code and modify the EmployeeFrame constructor to accept an
Employee variable called employee.
If you are unsure of how to do this, refer to the EmpFrame constructor as an example.
Create a private class Employee variable called emp.
1.
2.
In the constructor, assign employee to emp so that the initialize method will be able to
access the Employee object.
3.
In the initialize method, change the three label's setText statements so that the appropriate
property values from the Employee object are displayed.
 
Search WWH ::




Custom Search