Introduction
An applet is a tiny application built in Java. The applet is special in that it cannot easily access anything on your system outside of the browser. You can, though, now give the applet special privileges to do so. Applets can be found with such diverse functions as animation, image mapping, graphing, etc. When you add an applet to your page, you must have the class files present and correctly referenced for downloading to the client machine or the applet cannot run. This is true, also, of any other files that the applet uses. Usually, it is best to put all of the class files and associated files in the same directory. Most applets which you can download or purchase are limited in that they are not directly scriptable; i.e., you can place the applet on your page and fill in the associated parameters, but you cannot change those parameters on the fly.
Placing an Applet on the Page
Applets are place on a page between the tags, <Applet >and </Applet> Applets will usually a a list of parameters which are added between the tags that allow you to customize the applet for your use. However, a very simple applet may have no parameters. As an example, we will use a simple, useless applet called ColorCycle and follow it through a series of alterations into a useful tool. Here is the HTML that places the applet on the page:
<APPLET CODE="ColorCycle.class" CODEBASE="applets/colorcycle" ID="ColorCycle" ALT="Applet simply cycles through several aqua hues with button click." NAME="App_cc1" WIDTH="100" HEIGHT="100" ALIGN="LEFT" HSPACE="5" VSPACE="5"></APPLET>

Of the qualifiers which have been added to the applet tag, only CODE, HEIGHT, WIDTH, and CODEBASE are actually necessary to place the applet on the page. In general, an applet is handled similarly to an image tag; i.e., it can have HSPACE and VSPACE qualifiers which determine the 'clear' space around the applet, an ALT tag which appears whenever a browser is used that cannot display the applet. For purposes of DHTML, the applet can also have a NAME and ID, just as an image or any other tag can.

The CODE qualifier specifies the name of the class file which contains the applet. CODEBASE is necessary if the class file is not in the same directory as the page, especially if their are other files, such as images, needed by the applet.

Click several times on the 'Next Color' button in the applet. You will see that the color of the ellipse revolves through several hues of aqua. The applet is wholly self contained. You cannot change anything -- not even the background.

Introduction
Introduction

Netscape NOW!