|
Installing An Applet
To add an applet to an HTML page, you
need to use the <APPLET> HTML element.
<APPLET CODE="MyApplet.class"
WIDTH=150 HEIGHT=125>
</APPLET>
This tells the viewer or browser to load the applet whose compiled code is
in "MyApplet.class" (in the same directory as the current HTML
document), and to set the initial size of the applet to 150 pixels wide
and 125 pixels high.
Here's the complete syntax for the APPLET element:
<APPLET
[CODEBASE = codebaseURL]
CODE = appletFile
[ALT = alternateText]
[NAME = appletInstanceName]
WIDTH = pixels HEIGHT = pixels
[ALIGN = alignment]
[VSPACE = pixels] [HSPACE = pixels]
>
[<PARAM NAME = appletAttribute1 VALUE = value>]
[<PARAM NAME = appletAttribute2 VALUE = value>]
. . . . . . .
[alternateHTML]
</APPLET>
CODEBASE = codebaseURL
This optional attribute specifies the base URL of the applet -- the
directory that contains the applet's code. If this attribute is not
specified, then the document's URL is used.
CODE = appletFile
This required attribute gives the name of the file that contains the
applet's compiled Applet subclass. This file is relative to the base URL
of the applet. It cannot be absolute.
ALT = alternateText
This optional attribute specifies any text that should be displayed if the
browser understands the APPLET element but can't run applets written in
the Java(tm) Programming Language.
NAME = appletInstanceName
This optional attribute specifies a name for the applet instance, which
makes it possible for applets on the same page to find (and communicate
with) each other.
WIDTH = pixels HEIGHT = pixels
These required attributes give the initial width and height (in pixels) of
the applet display area, not counting any windows or dialogs that the
applet brings up.
ALIGN = alignment
This required attribute specifies the alignment of the applet. The possible
values of this attribute are the same as those for the IMG element: left,
right, top, texttop, middle, absmiddle, baseline, bottom, absbottom.
VSPACE = pixels HSPACE = pixels
These option attributes specify the number of pixels above and below the
applet (VSPACE) and on each side of the applet (HSPACE). They're treated
the same way as the IMG element's VSPACE and HSPACE attributes.
<PARAM NAME = appletAttribute1 VALUE = value>
This element is the only way to specify an applet-specific attribute.
Applets access their attributes with the getParameter() method.
Next article
|