Java Reference
In-Depth Information
3. When the applet is displayed, type 67 in the inches text box. Press the
TAB key.
4. Type 145 in the pounds text box.
5. Click the Calculate button.
The applet is displayed in the Applet Viewer window (Figure 3-49). The cal-
culated body mass index (BMI) is displayed, along with an output message.
heightField and
weightField
components
setForeground()
method causes
text to display
in red
calcButton
component
drawImage()
method
draws logo
calculated BMI
FIGURE 3-49
6. Click the Close button on the Applet Viewer window's title bar.
The Applet Viewer window closes, and the TextPad coding window again is
displayed.
To enter different data in the applet, you must close the Applet Viewer win-
dow and then execute the program again. In a later chapter, you will learn how
to write a clear event that will clear the sample data for the next person, without
having to close and execute the program again.
Once you have determined that the program runs correctly, you should print
a copy of the BodyMassApplet source code and the HTML host document code
for documentation purposes. You can print a copy of the program code from the
TextPad coding window by selecting the appropriate document in the Selector
window and then using the Print command on the File menu. A printout of the
program code will be sent to the default printer. Figure 3-47 on page 190 shows
the printout of the program code for the applet version of the Body Mass Index
Calculator. As previously noted, the longer lines of code wrap to the next line in
the printout.
 
Search WWH ::




Custom Search