Applets
An applet is a miniature program that you embed right into your web page. Applets themselves are not written in HTML... they are separate programs written in a language called
Java. Placing an applet in your page is like putting a little window in the middle of the page, and one of these Java programs is running in that window. You don't need a special web server to put applets in your web page... you can use the same server that serves your web pages.
If you are familiar with putting pictures in your web page, you will probably find that putting applets in your page is very similar (though not identical). The applet program (called a "class" file) is a separate file from your HTML file. You use the tags
<APPLET ...>
and
<PARAM ...>
to place the applet into your web page, much the same way you use
<IMG ...>
to place a picture in your page .
<APPLET ...>
calls the applet, <PARAM ...>
gives details on how to run the applet (called parameters). Anything else inside the <APPLET ...>
tag is ignored, so that's where you put information for browsers that don't understand applets.
For example, this HTML code calls an applet called "MyApplet", and tells MyApplet to display the words "Hi There":
this code |
produces this |
<APPLET CODE="MyApplet.class" WIDTH=200 HEIGHT=50>
<PARAM NAME=TEXT VALUE="Hi There">
<P>Hi There!<P>
</APPLET>
|
|
Here's what each piece means:
<APPLET CODE="MyApplet.class" WIDTH=200 HEIGHT=50>
- Run the applet "MyApplet.class". The area for the applet should be 200 x 50.
<PARAM NAME=TEXT VALUE="Hi There">
- Pass this information to the applet: the text (NAME=TEXT) should be "Hi There"
(VALUE="Hi There")
<P>Hi There<P>
- This is what is displayed in browsers that don't understand applets.
</APPLET>
- End of the code to run this applet.
The HTML for putting applets into a page is very standardized: you only need to learn a few tags and attributes. However, each applet has its own set of parameters which are used to make it run.
Since every applet is different, you need to know what parameters to use for each applet. For
example, the MyApplet applet requires you to use the TEXT parameter, but that's just
MyApplet; most applets have no such parameter. To learn how to use each applet, consult the
documentation for that applet.