Java Reference
In-Depth Information
In line 124, a user-defined method named clearFields() is called. You will
program the clearFields() method later in this chapter.
Lines 126 through 132 display the code that executes if the return value is
zero, indicating that no rooms are available. The program then evaluates the
state of the chosen option button and displays one of two error messages using a
JOptionPane dialog box. The input data is not cleared, but line 132 again selects
the hidden Checkbox so that the user can choose another option button on the
interface.
It is sometimes useful in long programs to place line comments at closing
braces, such as those in lines 133, 134, and 135, detailing which block of code is
being completed.
The step below enters the code for the actionPerformed() method.
To Enter Code for the actionPerformed() Method
1. Enter the code as shown in Figure 5-33. Use the TAB key to indent in
lines 116 through 123.
The TextPad window displays the actionPerformed() method (Figure 5-34).
Your lines may wrap differently.
check state of
hidden option
button
actionPerformed()
method
call to instance
method,
bookRoom()
set attributes
of TextArea
component to
define display
messages
display if
rooms are full
FIGURE 5-34
Search WWH ::




Custom Search