|
The APPLET Tag |
Documentation Contents |
Here is an example of a simple APPLET tag:
<applet code="MyApplet.class" width=100 height=140></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 100 pixels wide and 140 pixels high.
Here's a more complex example of an APPLET tag:
<applet codebase="http://java.sun.com/applets/NervousText/1.1"
code="NervousText.class" width=400 height=75>
<param name="text" value="Welcome to HotJava!">
<hr>
If you were using a Java-enabled browser such as HotJava,
you would see dancing text instead of this paragraph.
<hr>
</applet>
This tells the viewer or browser to load the applet whose compiled
code is at the URL
http://java.sun.com/applets/NervousText/1.1/NervousText.class,
to set the initial size of the applet to 400x75 pixels.
The viewer/browser must also
set the applet's "text" attribute (which customizes the text this
applet displays) to be "Welcome to HotJava!" If the page is
viewed by a browser that can't execute Java applets, then the browser
will ignore the APPLET and PARAM tags, displaying only the HTML between
the <param> and </applet> tags
(the alternate HTML).
Here's the result of putting the above example in your HTML file.
(The first time you load this page, you may have to wait for the applet
to be loaded.)
Here is another example of an APPLET tag:
<applet code=A21 width=256 height=256 archive="toir.jar">
<param name=img value=test.gif>
<hr>
We need to convert some of the standard applets to use
archive. Any volunteers?
<hr>
</applet>
In this example, the applet class is A21. Its bytecodes
(may) reside in the archive "toir.jar". This archive may
also contain the image resource (see resources documentation)
with name test.gif.
Here's the complete syntax for the APPLET tag. Required elements are in bold. Optional elements are in regular typeface. Elements your specify are in italics.
<APPLET
CODEBASE = codebaseURL
ARCHIVE = archiveList
CODE = appletFile ...or... OBJECT = serializedApplet
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>
CODE, CODEBASE, and so on are attributes of the applet tag; they give the browser information about the applet. The only mandatory attributes are CODE, WIDTH, and HEIGHT. Each attribute is described below.
.class or of the form
packagename.classname.class.
|
Copyright © 1995-98
Sun Microsystems, Inc.
All Rights Reserved.
Please send comments to: jdk-comments@java.sun.com |
Java Software |