When you build <APPLET> tags, keep in mind that words such as APPLET and CODEBASE can be typed in either as shown or in any mixture of uppercase and lowercase. Bold font indicates something you should type in exactly as shown (except that letters don't need to be uppercase). Italic font indicates that you must substitute a value for the word in italics. Square brackets ([ and ]) indicate that the contents of the brackets are optional.< APPLET [CODEBASE = codebaseURL] CODE = appletFile [ALT = alternateText] [NAME = appletInstanceName] WIDTH = pixels HEIGHT = pixels [ALIGN = alignment] [VSPACE = pixels] [HSPACE = pixels] > [< PARAM NAME = appletParameter1 VALUE = value >] [< PARAM NAME = appletParameter2 VALUE = value >] . . . [alternateHTML] </APPLET>
- CODEBASE = codebaseURL
- This optional attribute specifies the base URL of the applet -- the directory or folder 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 tag but can't run Java applets.
- 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 (and have the same effects) as those for the IMG tag: left, right, top, texttop, middle, absmiddle, baseline, bottom, absbottom.
- VSPACE = pixels
HSPACE = pixels
- These optional 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 tag's VSPACE and HSPACE attributes.
- < PARAM NAME = appletParameter1 VALUE = value >
- <PARAM> tags are the only way to specify applet-specific parameters. Applets read user-specified values for parameters with the
getParameter()method. See Defining and Using Applet Parameters for information about the
- If the HTML page containing this <APPLET> tag is viewed by a browser that doesn't understand the <APPLET> tag, then the browser will ignore the <APPLET> and <PARAM> tags, instead interpreting any other HTML code between the <APPLET> and </APPLET> tags. Java-compatible browsers ignore this extra HTML code.
In the online version of this tutorial, we use alternate HTML to show a snapshot of the applet running, with text explaining what the applet does. Other possibilities for this area are a link to a page that is more useful for the Java-ignorant browser, or text that taunts the user for not having a Java-compatible browser.