Java Reference
In-Depth Information
The step below illustrates entering the code for the main() method.
To Enter Code for the main() Method
1. Enter the code as shown in Figure 5-31.
The TextPad window displays the code for the main() method (Figure 5-32).
main() method
assigns Frame
attributes
FIGURE 5-32
Coding the actionPerformed() Method
The actionPerformed() method contains the code that will execute when the
user clicks the Book Room button. Recall from the flowchart in Figure 5-4 on
page 313, that the Book Room button should perform the following tasks:
1. It should make sure the user has selected an option button (nonsmoking
or smoking).
2. It should call the bookRoom() method of the Rooms object.
3. If a room is available, the program should change the display; otherwise, a
full message should display.
Figure 5-33 on the next page displays the code for the actionPerformed()
method. Three different if...else statements are used to test for the required con-
ditions. Line 104 evaluates the state of the hidden Checkbox. If the hidden
Search WWH ::




Custom Search