NOTE : The information provided here only describes the necessary HTML elements that allow pre-compiled HotJava applets to be added to your HTML documents. It does not describe how to actually write HotJava applets. Such information is well beyond the scope of this document. More information can be found about writing HotJava applets and how to obtain a copy of the HotJava browser and Java development kit from :
Also, Microsoft recently released their Java SDK, to complement their Visual J++ product. For more details, visit http://www.microsoft.com/java/
To add an applet to an HTML page, you need to use the <APPLET>
HTML element.
<APPLET CODE="Applet.class" WIDTH=200 HEIGHT=150>
</APPLET>
This tells the viewer or browser to load the applet whose compiled code is in Applet.class (in the same directory as the current HTML document), and to set the initial size of the applet to 200 pixels wide and 150 pixels high. (The <APPLET>
element supports standard image type attributes - see below).
Below is a more complex example of an <APPLET>
element:
<APPLET CODEBASE="http://java.sun.com/JDK-prebeta1/applets/
NervousText" CODE="NervousText.class"
width=400 height=75 align=center>
<PARAM NAME="text" VALUE="This is the Applet Viewer.">
<BLOCKQUOTE>
<HR>
If you were using a Java-enabled browser, you would see dancing text instead of this paragraph.
<HR>
</BLOCKQUOTE>
</APPLET>
This tells the viewer or browser to load the applet whose compiled code is at the URL http://java.sun.com/JDK-prebeta1/applets/NervousText/NervousText.class, to set the initial size of the applet to 400x75 pixels, and to align the applet in the centre of the line. The viewer/browser must also set the applet's "text" attribute (which customizes the text this applet displays) to be "This is the Applet Viewer." If the page is viewed by a browser that can't execute applets written in the Java Programming Language, then the browser will ignore the <APPLET>
and <PARAM>
elements, displaying the HTML between the <BLOCKQUOTE>
elements.
The complete syntax for the <APPLET>
element is as follows :
<APPLET
[ALIGN]="Alignment"
[ALT]="alternateText"
[ARCHIVE]="compressed_file"
[CLASS]="Style Sheet class"
[CODE]="appletFile"
[CODEBASE]="URL"
[DATAFLD]="Column Name"
[DATASRC]="Date Source"
[HEIGHT]="pixels"
[HSPACE]="pixels"
[ID]="Unique Identifier"
[MAYSCRIPT]
[NAME]="appletInstanceName"
[SRC]="URL"
[STYLE]="Styling"
[TITLE]="ToolTip"
[VSPACE]="pixels"
[WIDTH]="pixels"
>
[<PARAM NAME = appletAttribute1 VALUE = value>]
[<PARAM NAME = appletAttribute2 VALUE = value>]
. . .
[alternateHTML]
</APPLET>
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.
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 Programming Language.
ARCHIVE=compressed file
This optional attribute specifies the location (relative to the CODEBASE
of the main class file) of a compressed file (consisting of all the necessary class files and support images/sounds etc.) that may be downloaded to the users Hard Disk, to save download time should they return to the page at a later date. Any files not contained in this archive that are needed will be searched for by the browser in the normal way. NOTE : The ARCHIVE
attribute is Netscape specific.
CLASS=Style Sheet class
The CLASS
attribute is used to specify the <APPLET>
element as using a particular style sheet class. See the Style Sheets topic for details.
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.
CODEBASE=URL
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.
DATAFLD=Column Name
The DATAFLD
attribute can be used to specify a data column name from the Data source (see DATASRC
) that the <APPLET>
is bound to. For more information on the DATAFLD
attribute, see the Data Binding topic.
DATASRC=Data Source
The DATASRC
attribute can be used to specify a data source that the <APPLET>
is bound to. For more information on the DATASRC
attribute, see the Data Binding topic.
HEIGHT=pixels WIDTH=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.
HSPACE=pixels VSPACE=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.
ID=Unique Identifier
The ID
attribute can be used to either reference a unique style sheet identifier, or to provide a unique name for the <APPLET>
element for scripting purposes. Any <APPLET>
element with an ID
attribute can be directly manipulated in script by referencing its ID
attribute, rather than working through the All collection to determine the element. See the Scripting introduction topic for more information.
MAYSCRIPT
This attribute is a flag that when used, specifies that the applet is scriptable by JavaScript functions.
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.
SRC=URL
The SRC
attribute specifies a URL associated with the applet. Such a URL may point to the support site, with development information for example.
STYLE=Styling
As well as using previously defined style sheet settings, the <APPLET>
element can have in-line stylings attached to it. See the Style Sheets topic for details.
TITLE=ToolTip
The Internet Explorer 4.0 (and above) specific TITLE
attribute is used for informational purposes. If present, the value of the TITLE
attribute is presented as a ToolTip when the users mouse hovers over the <APPLET>
section.
<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.
The <PARAM>
element supports the following attributes:
DATAFLD
The DATAFLD
attribute can be used to specify a data column name from the Data source (see DATASRC
) that the <PARAM>
is bound to. For more information on the DATAFLD
attribute, see the Data Binding topic.
DATAFORMATAS
When the <PARAM>
element is data-bound, it can accept straight text, or HTML from the data source. The DATAFORMATAS
attribute should be set to "TEXT
" or "HTML
" accordingly. with DATAFORMATAS="HTML"
, the data provided for the <BUTTON>
element is parsed and rendered when its displayed.
For more information on the DATAFORMATAS
attribute, see the Data Binding topic.
DATASRC
The DATASRC
attribute can be used to specify a data source that the <PARAM>
is bound to. For more information on the DATASRC
attribute, see the Data Binding topic.
NAME
The NAME
attribute is used to specify which property of the specific attribute is being set, by the value of the VALUE
attribute.
VALUE
Specifies the value of the property named in the NAME
attribute.
Every <APPLET>
element in a document is an object that can be manipulated through scripting. Note that scripting of the <APPLET>
element/object is largely only supported by Internet Explorer 4.0 in its Dynamic HTML object model. Netscape does support the Applets collection/applets array, but the scripting opportunities are not as large as those supported by Internet Explorer 4.0.
<APPLET...>
Properties
The <APPLET...>
element/object supports all of the standard Dynamic HTML properties (i.e. className, document, id, innerHTML, innerText, isTextEdit, lang, language, offsetHeight, offsetLeft, offsetParent, offsetTop, offsetWidth, outerHTML, outerText, parentElement, parentTextEdit, sourceIndex, style, tagName and title). Details of these can be found in the standard Dynamic HTML properties topics.
Also, the <APPLET>
element supports the following properties:
align
The align
property directly reflects any settings of the ALIGN
attribute (see above).
code
The code
property directly reflects any settings of the CODE
attribute (see above).
codebase
The codebase
property directly reflects any settings of the CODEBASE
attribute (see above).
dataFld
The dataFld
property directly reflects any settings of the DATAFLD
attribute (see above).
dataSrc
The dataSrc
property directly reflects any settings of the DATASRC
attribute (see above).
height
The height
property directly reflects any settings of the HEIGHT
attribute (see above).
hspace
The hspace
property directly reflects any settings of the HSabovePACE
attribute (see above).
The readyState property can be one of 4 values, depending on the current state of the applet referenced in the <APPLET>
element. The possible values of the readyState
property are:
Value | Meaning |
complete |
The resource has completely loaded and is available to the document and therefore manipulation. |
interactive |
The resource hasn't completely downloaded, but is available to the document and scripting |
loading |
The resource is being downloaded |
uninitialized |
The resource is not available - normally, this value indicates that the resource is downloading |
src
The src
property directly reflects any settings of the SRC
attribute (see above).
vspace
The vspace
property directly reflects any settings of the VSPACE
attribute (see above).
width
The width
property directly reflects any settings of the WIDTH
attribute (see above).
<APPLET...>
Methods
The <APPLET...>
element/object supports all of the standard Dynamic HTML methods (i.e. click, contains, getAttribute, insertAdjacentHTML, insertAdjacentText, removeAttribute, scrollIntoView and setAttribute). Details of these can be found in the standard Dynamic HTML Methods topics.
The <APPLET>
element also supports the following methods:
blur
The blur
method can be used to force the applet to lose the users focus. This then fires the onblur
event (see below).
focus
The focus
method can be used to force the applet to gain the users focus. This then fires the onfocus
event (see below).
<APPLET...>
Events
The <APPLET...>
element/object supports all of the standard Dynamic HTML events (i.e. onclick, ondblclick, ondragstart, onfilterchange, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup and onselectstart). Details of these can be found in the standard Dynamic HTML events topics.
The <APPLET>
element also supports the following events:
onafterupdate
The onafterupdate
event is fired after data is transferred from the element to the data provider and will only fire after the onbeforeupdate
event has fired and was successful. For more information on Data Binding, see the Data Binding topic.
onbeforeupdate
onbeforeupdate
fires when a data bound element loses the focus, or the current document is unloaded and will only fire if the value of the element is different to the original value that was present when the element received the users focus. Note that onbeforeupdate
is a cancelable event (setting returnValue=false
for the Event object), which allows the document /script author a chance to validate the new data entered by the user on the client-side, before sending the data to the data provider. For more information on Data Binding, see the Data Binding topic.
onblur
onblur
is fired whenever the users focus moves away from the applet (either by them clicking on another part of the document, or by 'tabbing' away from the contents of the <APPLET>
element, or by using the blur
method (see above).
ondataavailable
The ondataavailable
event being fired indicates that more records for the referenced Data Source Object are available. It doesn't necessarily fire for every single additional record though. For more information on Data Binding, see the Data Binding topic.
ondatasetchanged
The ondatasetchanged
event is fired when a new set of data is available and a recordset can be retrieved from that set of data, or when an existing set of data has been changed - for example after a filter has been applied to the data. For more information on Data Binding, see the Data Binding topic.
ondatasetcomplete
When all the data in the referenced recordset is available, the ondatasetcomplete
event fires. For the ondatasetcomplete
event, a reason
parameter is available through the Event Object, which can have values of 0, 1 or 2, corresponding to successful completion, Aborted completion (i.e. 'Stop' button pressed for example), or Error (some other error) respectively. For more information on Data Binding, see the Data Binding topic.
onerrorupdate
The onerrorupdate
event fires when a data transfer error occurs, through some action by the user (i.e. pressing the 'Stop' button on the browser for example), but not if a script generates the transfer error. For more information on Data Binding, see the Data Binding topic.
onfocus
The onfocus
event is fired whenever the user passes the focus to the applet - by clicking on it, tabbing to it, or by a script function using the focus
method (see above).
onload
The onload
event is fired when the applet referenced in the <APPLET>
element starts to download. Note that the event is fired as soon as the <APPLET>
element is encountered, so any script functions fired from the onload
event should be before the referenced <APPLET>
element in the document, otherwise script errors will occur.
onreadystatechange
At any time, the applet may change its readyState
property and when this happens, the onreadystatechange
event is fired.
onresize
The onresize
event is fired whenever the applet is resized, through scripting, or by the user changing their browser window size.
onrowenter
The onrowenter
event fires on the data source control when the current record has been changed, so new data is available to populate the HTML display elements that are bound to the data source. Somewhat confusingly, this will typically happen after the onrowexit
event has been fired. For more information on Data Binding, see the Data Binding topic.
onrowexit
The onrowexit
event is fired immediately before the data source changes the current record (i.e. when the user has requested another record, or set of records by pressing a button perhaps). Note that unlike the anafterupdate
and onbeforeupdate
events, onrowexit
is fired by the data source, not any of the HTML elements used to display the data. Changes to the data in the HTML elements should have been transferred to the data source (with validation being taken care of in the on*update
events). onrowexit
will also fire if the record position is changed through scripting. For more information on Data Binding, see the Data Binding topic.
© 1995-1998, Stephen Le Hunte
file: /Techref/language/html/ib/Media_Embedding/applet.htm, 25KB, , updated: 2004/3/1 16:47, local time: 2024/10/14 10:42,
98.80.143.34:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/Techref/language/html/ib/Media_Embedding/applet.htm"> <APPLET></A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.