Java Reference
In-Depth Information
input
prompts
text boxes
button
company
logo
FIGURE 3-4c
Consistent Wording in Applications and Applets
When designing different versions of the same program, as you do
when you convert console applications to applets, be sure to code
prompts and output messages so that the wording is as similar as
possible. Consistent wording will allow users to interpret easily
what the program is asking and make it easier if they have to
switch between program versions running on a desktop, on a
PDA, or via the Web. It also will simplify the programming pro-
cess, especially if you are editing existing code to create a differ-
ent version of the program.
PROGRAM DESIGN Once you have designed the interface, the next step is to
design the logic to solve the problem and create the desired results. The only
programming task is to calculate the BMI based on input. The user can execute
the program code to calculate BMI by answering the prompts in any version of
the application program. The applet requires the additional step of clicking the
Calculate button.
The program code for the first console application will allow user input,
perform calculations, and display an answer, in that order, so the structure of the
program will be sequential in nature. Input prompts and output will display
using the System.out object, which is the default display device of your system
(Figure 3-1a on page 129).
The program code then will be modified to use dialog boxes. This second
version of the application will call on a special Java package named javax.swing ,
which provides a set of Java-based GUI components (Figure 3-1b on page 129).
Finally, the program code will be modified to create a third version of the
program that can run over the Web as an applet. The program code for the
applet will display text, text boxes, a button, and a graphic in an applet window
(Figure 3-1c on page 129). Both the application and applet versions of the
program should contain appropriate documentation and be saved for future use.
 
Search WWH ::




Custom Search