Java Reference
In-Depth Information
The EmployeeApp executable code should look like the following:
package c4;
public class EmployeeApp {
public static void main(String[] args) {
Employee emp= new Employee("Mary Worker", "1 Main
St.", "Enid", "OK", "77777");
EmployeeFrame ef= new EmployeeFrame(emp);
}
}
Tutorial: Breaking the Code with VE
Not only does VE make building a GUI very easy, but because the GUI is displayed while being defined, the
programmer is much less likely to make mistakes. For instance, in VE the programmer can easily see when labels
overlap. When specifying locations in the source, it is very difficult for a programmer to “see” where all components
are in relation to one another. In addition, it usually takes the programmer many attempts to define the component
sizes and spacing so that they are visually appealing. However, even with all of VE's wonderful features, the
programmer can still screw up.
1.
In the EmployeeFrame Design view, drag the second label (streetLbl) so that it overlaps
the first label (nameLbl) and save the source code.
Notice that VE lets you define overlapping components and doesn't even generate an error message.
Click Edit , and then Undo Typing .
2.
Notice that Undo lets you reverse changes even after the source code has been saved. However, because Undo
made a new change (the reversal), the code needs to be saved again.
3.
Select all three labels. (The order does not matter this time.)
The style, size, and color of text can be specified for many visual components. In this case, we will change the size
and color of all three labels at once.
4.
In the Properties view, click on the background property to display the property value
button, and then display the Java Property Editor by clicking on the value button.
5.
Select Yellow and then click the OK button.
6.
Display the Java Property Editor for the foreground property.
7.
Select Blue and then click the OK button.
8.
Display the Java Property Editor for the font property.
9.
In the Size pane, select 36 for the text size and click OK.
EmployeeFrame should look like Figure 4-14 . Notice anything wrong?
 
Search WWH ::




Custom Search