img
The HTML APPLET Tag
As mentioned earlier, Sun currently recommends that the APPLET tag be used to start an
applet from both an HTML document and from an applet viewer. An applet viewer will
execute each APPLET tag that it finds in a separate window, while web browsers will allow
many applets on a single page. So far, we have been using only a simplified form of the
APPLET tag. Now it is time to take a closer look at it.
The syntax for a fuller form of the APPLET tag is shown here. Bracketed items are
optional.
< APPLET
[CODEBASE = codebaseURL]
CODE = appletFile
[ALT = alternateText]
[NAME = appletInstanceName]
WIDTH = pixels HEIGHT = pixels
[ALIGN = alignment]
[VSPACE = pixels] [HSPACE = pixels]
>
[< PARAM NAME = AttributeName VALUE = AttributeValue>]
[< PARAM NAME = AttributeName2 VALUE = AttributeValue>]
...
[HTML Displayed in the absence of Java]
</APPLET>
Let's take a look at each part now.
CODEBASE  CODEBASE is an optional attribute that specifies the base URL of the applet
code, which is the directory that will be searched for the applet's executable class file
(specified by the CODE tag). The HTML document's URL directory is used as the CODEBASE
if this attribute is not specified. The CODEBASE does not have to be on the host from which
the HTML document was read.
CODE  CODE is a required attribute that gives the name of the file containing your applet's
compiled .class file. This file is relative to the code base URL of the applet, which is the
directory that the HTML file was in or the directory indicated by CODEBASE if set.
ALT  The ALT tag is an optional attribute used to specify a short text message that should
be displayed if the browser recognizes the APPLET tag but can't currently run Java applets.
This is distinct from the alternate HTML you provide for browsers that don't support applets.
NAME  NAME is an optional attribute used to specify a name for the applet instance.
Applets must be named in order for other applets on the same page to find them by name
and communicate with them. To obtain an applet by name, use getApplet( ), which is defined
by the AppletContext interface.
WIDTH and HEIGHT  WIDTH and HEIGHT are required attributes that give the size (in pixels)
of the applet display area.
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home