[an error occurred while processing this directive] Applet Tag Settings

This page describes in detail the different required and optional settings used in the HTML tags for launching Java applets. The parameters described here are:

The syntax for using these settings is found on the introductory page on using Java applets with your WebCom account.


Required Settings CODE

code=Filename.class

The code attribute is used to specify the file containing the executable Java applet, which is usually a file named Filename.class. For instance, if the Java applet is named NeatAnimation.class, then the tag which would launch this applet might look something like this:

<applet code=NeatAnimation.class height=200 width=300>
</applet>

This tag will look for the NeatAnimation.class file in the current directory (the same directory that the page containing this tag is in). The CODE setting can also work in conjunction with the optional CODEBASE attribute to find an applet which is not in the current directory.

HEIGHT / WIDTH

Each Java applet needs to be launched within a pre-defined box on the web page containing it. The dimensions of this box are, not surprisingly, defined by the WIDTH and HEIGHT attributes, in values representing the number of pixels. An example of how these are used in the applet tag would be:

<applet code=AnimatedBanner.class height=50 width=200>
</applet>


Optional Settings CODEBASE

This setting is used to define the directory where the file specified by CODE can be found, and is the base URL of any references the applet needs to make in its execution (i.e., where it will find auxiliary graphics, sounds, etc.). If CODEBASE is not defined, the default is the directory of the web page launching the applet.

This can be particularly useful in keeping your applets well organized in your site. For instance, if you wished to keep your applets in their own special directories, nested inside a main 'applet" directory within your www directory, like this:

www
  |
  |-applets
         |
         |-DancingBears
         |
         |-AnotherApplet

You could then use CODEBASE in your site's homepage (welcome.html) to call these applets, as in:

<applet code=DancingBears.class height=100 width=100 codebase=applets/DancingBears>
</applet>

ALIGN

This parameter specifies the positioning of the applet on the page, and works similar to how ALIGN works in other HTML tags, such as the IMG tag. The values which can be specified with ALIGN are left, right, top, texttop, middle, absmiddle, baseline, bottom, and absbottom. This attribute can be set in the following way:

<applet code=MyGame.class height=250 width=250 align=right>
</applet>

This will cause the box containing the executing applet to be flush to the right side of the browser's window.

HSPACE

HSPACE is used to define the horizontal space surrounding the applet, and only works when the ALIGN attribute is set as either left or right. An example of its use would be:

<applet code=MyGame.class height=250 width=250 align=right hspace=10>
</applet>

VSPACE

VSPACE is used to define the vertical space surrounding the applet, and only works when ALIGN attribute is set as either left or right. An example of its use would be:

<applet code=MyGame.class height=250 width=250 align=right vspace=15>
</applet>

NAME

The NAME parameter can be used to give the applet a unique name. When other applets on the same page need to locate this applet, they use the name defined here. An example of an applet tag which uses the NAME parameter would be:

<applet code=AppUsedByAnother.class height=10 width=50 name=CallMe>
</applet>

The result of this would be that another applet on the same page could make use of this applet by referring to "CallMe".

[an error occurred while processing this directive]