A Complete Guide to Web Design

(やまだぃちぅ) #1
372 Chapter 21 – Interactivity

Java Applets


Web Design in a Nutshell, eMatter Edition

applets available for free or for a licensing fee that you can download from
libraries on the Web.
A good place to start is the applets section of Sun’s Java site athttp://java.sun.com/
applets/. This page provides a list of links to applet-related resources.
If you are looking for cool applets you can use right away, try the JavaBoutique at
http://javaboutique.internet.com/. Here you will find hundreds of applets available
for download as well as clear instructions for their use. It’s a great way to add
interactivity to your site without learning any programming.
In addition to these, there are a number of small businesses with Java applet pack-
ages for sale or available for a nominal licensing fee. Because the list is constantly
changing, I recommend doing a search for “Java Applets” on Yahoo (http://www.
yahoo.com) or your favorite search engine.

Adding an Applet to a Page


It is fairly easy to download an applet and add it to a web page. The steps below
follow the instructions provided by the JavaBoutique for downloading applets
from their site, but they can be used for applets from any resource.


  1. Download the.classfile along with any associated image or audio files. (Note,
    there is a bug in Netscape 4.0 that requires you to hold the Shift key before
    clicking the link for the.classfile). In some cases, you may be given the raw
    Java code, in which case you would need to compile it using Sun’s Java
    Developer Kit.

  2. The.classfile should be saved in the same directory as the HTML file unless
    otherwise noted by thecodebaseattribute in the associatedtag
    (this attribute gives the path for the applet). If the applet requires additional
    resources (such as image or audio files), be sure to save them in the same
    directory structure you found them (or follow the directions provided with the
    applet).
  3. When getting an applet from a library such as JavaBoutique, the required
    HTML source is made available with the download, so you can just copy and
    paste it into your HTML document and adjust the parameters as necessary.
    Applets are generally placed on web pages using thetag. Some
    applets also require that parameters be set or customized withtags,
    which are placed within the opening and closing tags. Thetag and all its attributes are discussed in detail in Chapter 9,
    Adding Images and Other Page Elements. The following shows two typical
    tags.
    The first is quite simple and contains only the required attributes:


    The second contains additional parameters :
    HEIGHT="280">