Java Reference
In-Depth Information
Compiling the Applet
The following step compiles the BodyMassApplet source code.
To Compile the Applet
OTHER WAYS
1. With the Data Disk in drive A, click Tools on the menu bar and then click
Compile Java on the Tools menu.
TextPad automatically saves and then compiles the BodyMassApplet source
code. If TextPad notifies you of compilation errors, fix the errors in the
BodyMassApplet coding window and then compile the program again.
1. Press CTRL + 1
2. At command
prompt, type javac
BodyMassApplet
.java
Correcting Errors
In TextPad's Command Results window, you can double-click the
first line in an error message to move the insertion point to that
error in the coding window, thus eliminating the searching and
scrolling necessary to locate the referenced line number.
Creating an HTML Host Document
for an Interactive Applet
You may remember that, because an applet is initiated and executed from
within another language or run as a part of a Web page, you must identify a
host, or reference program, to execute the applet. The interactive Body Mass
Index Calculator applet will run as part of an HTML host document that tells
the browser, through the use of tags, the name of the applet and the size of the
window. HTML hosts may contain other tags as well.
Creating the Host Document
You will use the <HTML> tag and the <APPLET> tag in the host document.
The following steps create the HTML host document using TextPad.
To Create the HTML Host Document
1. With the TextPad window open, click the New Document button on the
Standard toolbar. If line numbers do not display, click Line Numbers on
the View menu.
2. In the TextPad coding window, type the code as shown in Figure 3-48
on the next page.
(continued)
Search WWH ::




Custom Search