Java Reference
In-Depth Information
7.
Move the add empNameLbl statement after the add empCSZLbl statement.
Can you figure out how the data will appear?
8.
Save EmpFrame and run EmployeeApp.
The data should appear as in Figure 3-30 . Can you explain why the data appears as in Figure 3-30 ?
Figure 3-30.
In step 6, the add statements were changed such that empStreet was the first and, therefore, primary label.
In other words, the empStreet text will overlay any other label. Next, empCSZ was added under empStreet. Since
empStreet is 60 pixels long, only empCSZ's pixels 61 through 150 are displayed (i.e., “77777”). Lastly, empName
is added beneath both empStreet and empCSZ. Because empName is only 30 pixels in length, none of
empName appears.
9.
End EmployeeApp.
10.
Move the add empName statement before the add empStreet and set the label locations
and lengths back to the original values as follows:
empNameLbl.setBounds(100, 150, 150 , 20);
empStreetLbl.setBounds(100, 190 , 150 , 20);
empCSZLbl.setBounds(100, 230 , 150, 20);
11.
Test that it is correct, by saving the source and running the application.
12. Comment out the Label import statement.
Notice that 12 errors were generated. Every statement that references a label is in error because the JVM cannot
find the Label class. It is very common error to forget to include the import statement.
13.
Uncomment the import statement and save the source.
Search WWH ::




Custom Search