Previous ION Java User's Guide: Using ION's Pre-Built Applets Next

The <APPLET> Tag

The HTML <APPLET> tag is used to include Java applets in your HTML code. For more information on embedding applets into a web page, consult an HTML manual The syntax of the <APPLET> tag is as follows:

<APPLET
[ALIGN={"left" | "right" |"top" | "middle" | "bottom"}]
[ALT="alternate text"]
[ARCHIVE="zip or jar file"]
CODE="class file"
[CODEBASE="path or URL"]
HEIGHT="height"
[HSPACE="pixels"]
[NAME="name"]
[VSPACE="pixels"]
WIDTH="width" >
</APPLET>

Attributes

The <APPLET> tag takes the following attributes:

ALIGN

ALIGN specifies either the position of the applet in relation to the left and right borders of the browser, or the alignment of text in relation to the applet:

ALT

The ALT attribute specifies a text string to be displayed if for some reason the applet cannot be loaded. The ALT attribute is not required, but consider adding something like the following to your applet description to enhance the user-friendliness of your HTML page:

ALT="ION Applet failed to load. Is Java enabled in your browser?"  

 


Note
If you include HTML-formatted text within your <APPLET> tag, it will be displayed only if the Java Virtual Machine fails to start. This is slightly different from the ALT attribute, which contains text to be displayed only if the Java applet fails to load.

ARCHIVE

The ARCHIVE attribute is not required. However, it is recommended that you download all of the ION classes as a single package. See Supporting Java Archive Files for a discussion of Java archive files.

CODE

A string specifying the name of the applet class. The CODE attribute should specify the fully-qualified class name relative to the directory in which the HTML file is located. If the CODEBASE attribute is included, the class name specified in the CODE attribute should be relative to the directory specified by CODEBASE.

For example, if you were to place an HTML file that used the IONPlotApplet in an html subdirectory of the ION directory, the CODE, CODEBASE and ARCHIVE attributes would be:

CODE=com.itt.ion.IONPlotApplet.class  
CODEBASE="../classes"  
ARCHIVE="ion_64.jar"  

because the IONPlotApplet.class file is located in the com/itt/ion subdirectory within the ION .jar file. Similarly, if you were to place all of the Java class files necessary for your applet in the directory containing your HTML files, you could omit the CODEBASE attribute and use something like the following:

CODE=MyApplet.class  

The CODE attribute is required for all ION applets.

CODEBASE

The CODEBASE attribute is not strictly required, but is often useful. The Java class loader searches for the contents of the classes directory in current directory — that is, the directory from which the HTML page containing the <APPLET> tag was loaded. If you locate the HTML page somewhere other than the IONJava/classes directory, you will need to set the CODEBASE attribute to the relative path from the page location to the classes directory, or to a URL that specifies the location.

For example, if your HTML page is located in a directory called /ITT/IDL63/products/ION63/ion_java/html, you would set the CODEBASE attribute as follows:

CODEBASE="../classes"  

 


Note
If the CODEBASE attribute is set equal to a URL, then the host specified by the URL can be used for ION network connections, but the host that is serving the HTML page cannot. This allows you to set up the ION Server and all of the ION class files on a machine separate from your web server, provided you include the SERVER_NAME parameter with the same hostname as in the CODEBASE URL. If you use this method, both the CODEBASE and SERVER_NAME attributes must refer to the same machine or Java security errors will result. In addition, the ION Server machine will still need to run a web server, but it will only be used to get the .class (or archive) files for the applets.

HEIGHT

The height of the applet in pixels. ION uses the HEIGHT attribute when creating the drawing area. This attribute is required for all ION applets.

HSPACE

The amount of white space to the left and right of the applet, in pixels.

NAME

A string containing a unique name for the applet. The string should be enclosed in double quotes marks. This attribute is required for all ION applets.

WIDTH

The width of the applet in pixels. ION uses the WIDTH attribute when creating the drawing area. This attribute is required for all ION applets.

VSPACE

The amount of white space on the top and bottom of the applet, in pixels.

Example

The following <APPLET> tag creates an applet of the IONGraphicApplet class, with a drawing area 100 pixels by 100 pixels, with the name "MyApplet." The HTML page containing the applet code is assumed to be located in the directory /ITT/IDL63/products/ION63/classes, so no CODEBASE attribute is included.

<APPLET NAME="MyApplet" WIDTH=100 HEIGHT=100  
    CODE=com.itt.ion.IONGraphicApplet.class  
<!- Other applet code >  
</APPLET>  

Supporting Java-Incapable Browsers

You can include HTML text within an applet tag, but the text will only be displayed if the Java virtual machine fails to start. You may find it useful to include something like the following:

<APPLET attributes>  
   <!-- Applet code -->  
   <B>Java virtual machine failed to start.   
   Is Java enabled in your browser? </B>  
</APPLET>  

People with browsers that do not support Java would see the text:

Java virtual machine failed to start. Is Java enabled on your browser?

while those with browsers that do support Java would see only the applet.

  IDL Online Help (March 06, 2007)