Java Reference
In-Depth Information
Five message and dialog boxes summarized in Table 8-2 will be needed. The
solution should use one of the JOptionPane show() methods to specify the type
of box that displays with the appropriate title, prompt, icon, and buttons.
Table 8-2 BillPayer Message and Dialog Boxes
TYPE OF BOX
TITLE
PROMPT
ICON
BUTTONS
1
MessageDialog
Error
The UIManager could not set the Look
Information
OK
and Feel for this application.
2
MessageDialog
Error
The program could not create a storage
Information
OK
location. Please check the disk drive and
then run the program again.
3
ConfirmDialog
File
Are you sure you want to exit
Question
YES/NO
Submission
and submit the file?
4
MessageDialog
Submission
The payment information has been saved.
Information
OK
Successful
5
MessageDialog
Data Entry
You must complete all fields.
Warning
OK
Error
Box 1 displays if the program generates an
exception because it is unable to access the chosen
Look and Feel. Box 2 displays if the program gen-
erates an exception because the disk is full or the
program cannot access the secondary storage
device. Box 3 displays when the user clicks the
Close button on the title bar. Box 4 displays when
the user clicks the Submit button. Finally, Box 5
displays if the user clicks the Submit button and
one or more of the text boxes are empty.
Create BillPayer application
Construct components
Construct window and set attributes
Add components to window
Try to open output file
If storage is inaccessible
Notify user
Exit program
PROGRAM DESIGN Once the interface is
designed, the next step is to design the logic to
solve the problem and create the desired results.
Figure 8-4 shows the pseudocode that represents
the logic of the program.
After the interface components are con-
structed and added to the appropriate containers,
the program should open the sequential file and
display the interface. The user then has three pos-
sible choices: enter data into the text fields, click
the Submit button, or click the Close button on
the title bar. If the user clicks the Submit button
with a field blank, the program should display an
error message; otherwise, the data should be writ-
ten to the sequential file, and a submission mes-
sage should display. In order to maximize the
speed of data entry, users will not be required to
enter the payment amount using a certain format.
Display interface
When Close button is clicked
Display confirmation display box
If yes
Close program
Else
Return to interface
When Submit button is clicked
If any field is empty
error message
Display
Return to interface
Else
Write data to disk
Display submission message
Clear fields
Return to interface
End BillPayer application
FIGURE 8-4
 
Search WWH ::




Custom Search