Java Reference
In-Depth Information
PROBLEM ANALYSIS A clear and easy interface needs to be designed to
maximize user efficiency for the BillPayer program. The program should accept
eight fields of information from the user and then write the data to a sequential
data file. The program should test that all eight fields have been completed.
The user must be notified by the program when the data has been submitted
successfully, and the program should clear all eight fields for the next entry.
Additionally, to prevent users from inadvertently closing the file without saving
before the end of the day, the user must be notified when the entire file is ready
to be saved permanently. Each day creates a new and different data file that will
be uploaded external to the program; therefore, it is important that the file name
include the date. The date will ensure that each file name is unique and cannot
be overwritten. The program also should include appropriate prompts and mes-
sages, such as a confirmation dialog box that displays when the user attempts to
exit the program.
DESIGN THE SOLUTION Once the problem has been analyzed, the next step
is to design the user interface and the logic to solve the problem. The program is
designed in three stages. First, the window is created. Second, the components
are added to the interface with appropriate labels, text boxes, and a button.
Finally, functionality is added to the components so that users can enter data
and store it in a sequential file. The BillPayer program has a single interface that
can generate various dialog message boxes. Crandall Power and Light has chosen
the Swing Motif Look and Feel for the interface. Because the rows vary in the
number of elements they can hold and they each have different widths, each row
of components will be stored in its own panel. A storyboard labeling the panels
and layouts is shown in Figure 8-3. Using Java's BorderLayout manager, the
JPanels, which contain JLabels and JTextFields, are placed in the Center area; the
JPanel containing the Submit button is placed in the South area.
eight individual
panels, each
formatted to use
FlowLayout, left-
justified
center panel
to hold all
rows
south panel to
hold button
FIGURE 8-3
 
Search WWH ::




Custom Search