Java Applets :

When you put an applet on your page you will need to save the applet on your server as well as the HTML page the applet is embedded in. When the page is loaded by a visitor the applet will be loaded and inserted on the page where you embedded it.

Applets have the file extension "class". An example would be "myapplet.class". Some applets consist of more than just one class file, and often other files need to be present for the applet to run (such as JPG or GIF images used by the applet). Make sure to check the documentation for the applet to see if you have all files for it to run.
Before embedding an applet on your page you need to upload the required files to your server.

Below is a short example showing how simple it is to embed an applet on a page.

<Title>Java Example</Title>

This is my page<br>
Below you see an applet<br>
<Applet Code="MyApplet.class" width=200 Height=100>

Two HTML tags are relevant according to applets: <Applet> and <Param>.

The <Applet> tag embeds the applet in your HTML page.
The <Param> tag is used to enter parameters for the applet.

The following attributes can be set for the <Applet> tag:

Attribute Explanation Example
Code Name of class file Code="myapplet.class"
Width=n n=Width of applet Width=200
Height=n n=Height of applet Height=100
Codebase Library where the applet is stored.
If the applet is in same directory as
your page this can be omitted.
Alt="Text" Text that will be shown in browsers where the ability to show applets has been turned off. alt="Menu Applet"
Name=Name Assigning a name to an applet can
be used when applets should
communicate with each other.
Justifies the applet according to the
text and images surrounding it.
A full explanation of the individual
parameters is given here.
Vspace=n Space over and under the applet. Vspace=20
Hspace=n Space to the left and right of applet. Hspace=40

The <Param> tag has the general syntax:
<Param Name=NameOfParameter Value="ValueOfParameter">

Each applet has different parameters that should be set.
Typical parameters for an applet would be:
  • color used by the applet

  • font and font size to be used on text in the applet

  • name of an image file to be inserted in the applet

To see which paramters should be set by a specific applet, you will need to read the documentation for that applet. It will list names and possible values for parameters.



     "Better Than Books - As Easy As It Gets!"