Java Reference
In-Depth Information
For more information on the JNLP XML and how it applies to applets, go to http://
java.sun.com/javase/6/docs/technotes/guides/jweb/applet/applet_deployment.html#
jnlp_href. For a detailed description on the JNLP XML, go to http://java.sun.com/
javase/6/docs/technotes/guides/javaws/developersguide/syntax.html.
JavaFX Applet Launch JavaScript
To make JavaFX applet deployment easier and portable across browsers, Sun has
developed a JavaScript function for launching JavaFX applets. This JavaScript
function is defined as javafx(launchParams, appletParams) . The second param-
eter, appletParams , is optional. To include this JavaScript code into your HTML
page, you must first reference it. The standardized location for this JavaScript
code is http://dl.javafx.com/dtfx.js. An example of using this in an HTML page is
<script src="http://dl.javafx.com/dtfx.js"></script>
Including this script provides JavaScript functions for automatic checking for the
correct Java version and defines the JavaScript function for loading the appropri-
ate JavaFX runtime archive files.
To use the JavaFX launch function, javafx() , in an HTML page, include it
within a JavaScript section as shown in Listing 9.2.
Listing 9.2
JavaScript for Launching JavaFX Applet in a Browser
<script>
javafx(
{
archive: "NasaImageBrowser.jar",
width: 500,
height: 500,
code: "nasaimagebrowser.Main",
name: "NasaImageBrowser"
}
);
</script>
Listing 9.3 shows using the JavaFX Applet launcher function in an HTML page.
The JavaScript code for the applet is shown in bold and includes two script sections.
Listing 9.3
JavaFX Launcher Script in HTML Page
<html>
<head>
<title>Nasa Image Browser</title>
</head>
Search WWH ::




Custom Search