Running Applets

Applets run in Web browsers and are loaded through HTML applet tags. The most important tags are covered here. Listing 9.1 shows sample HTML for running an applet.

Code Listing 9.1. Sample HTML to Run an Applet (MyApplet.html)
<HTML>
<Title>
This is a sample Applet HTML file
</Title>
<BODY>
<APPLET code=MyApplet  archive=Myjar.jar
width=400 height=300
codebase=http://www.gradschoollibrary.edu/Applets
alternatetxt="Get a Java-enabled browser"
vgap =5 hgap=5
<param name=imagefile >
value=http://www.gradschoollibrary/Applets/images/libraryentrace.gif>
</APPLET>
</BODY>
</HTML>

This book does not cover HTML, so the non-applet tags will not be discussed. In the order in which they appear, here is what each tag does.

The <APPLET> ...

Get PURE Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.