JavaFX – Where is Applet tag?!


For deploying JavaFX in browser, we use JavaScript code as shown below


<script src="http://dl.javafx.com/1.1/dtfx.js&#34;></script>
<script>
    javafx(
        {
              archive: "JavaFX_Flickr_Image_Viewer.jar",
              draggable: true,
              width: 800,
              height: 650,
              code: "carousel.Main",
              name: "JavaFX_Flickr_Image_Viewer"
        }
    );
</script>

JavaFX uses dtfx.js which in turn uses deployJava.js to detect presence of java, the version of java on the system etc. Refer to Java Deployment Toolkit documentation for more information.

So how does JavaFX deploys as Applet without using Applet tag?

It indeed uses Applet tag, dtfx.js script generates the required Applet tag. It generates two <div> sections. The first section shows the spinning java logo and second sections embeds the Applet. First the spinning logo is shown, when applet is loaded, its visibility status is changed to false.

The generated html tags will be as shown below, which has embedded Applet tag



<script src="http://dl.javafx.com/1.1/dtfx.js&#34;></script>
<div id="deployJavaApplet1Overlay" 
    style="width:800;height:650;position:absolute;background:white">
    <table width=800 height=650 border=padding=margin=0>
    <tr><td align="center" valign="middle">
        <img src="http://dl.javafx.com/javafx-loading-100x100.gif"&nbsp;width=100 imgHeight=100>
    </td></tr>
    </table>
</div>
<div id="deployJavaApplet1" style="position:relative;left:-10000px">
    <APPLET MAYSCRIPT
        code="org.jdesktop.applet.util.JNLPAppletLauncher"
        archive="JavaFX_Flickr_Image_Viewer.jar,
        http://dl.javafx.com/applet-launcher__V1.1.1.jar,
        http://dl.javafx.com/javafx-rt__V1.1.1.jar,
        http://dl.javafx.com/fxdloader__V1.1.1.jar,
        http://dl.javafx.com/jmc__V1.1.1.jar,
        http://dl.javafx.com/Decora-SSE__V1.1.1.jar,
        http://dl.javafx.com/emptyJarFile-1239792034654__V1.1.1.jar&#34;
        width=800
        height=650>
        <param name="codebase_lookup" value="false">
        <param name="subapplet.classname" value="com.sun.javafx.runtime.adapter.Applet">
        <param name="progressbar" value="false">
        <param name="classloader_cache" value="false">
        <param name="draggable" value="true">
        <param name="MainJavaFXScript" value="carousel.Main">
        <param name="subapplet.displayname" value="JavaFX_Flickr_Image_Viewer">
        <param name="jnlpNumExtensions" value="2">
        <param name="jnlpExtension1" value="http://dl.javafx.com/jmc__V1.1.1.jnlp&#34;>
        <param name="jnlpExtension2" value="http://dl.javafx.com/Decora__V1.1.1.jnlp&#34;>
        <param name="jnlp_href" value="JavaFX_Flickr_Image_Viewer_browser.jnlp">
        <param name="deployJavaAppletID" value="deployJavaApplet1">
    </APPLET>
</div>

How will we get this generated Applet tag?

Just add displayhtml: true as shown below. This will display the html instead of loading the applet!


<script src="http://dl.javafx.com/1.1/dtfx.js&#34;></script>
<script>
    javafx(
        {
              archive: "JavaFX_Flickr_Image_Viewer.jar",
              draggable: true,
              width: 800,
              height: 650,
              code: "carousel.Main",
              name: "JavaFX_Flickr_Image_Viewer",
              displayhtml: true

        }
    );
</script>

var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_sudoku_css_support&#8221;;
var dzone_style = ‘2’;

digg_skin = ‘compact’;
digg_window = ‘new’;

Advertisements

About Rakesh Menon
-

8 Responses to JavaFX – Where is Applet tag?!

  1. David Miles says:

    Good article. I did not know about the displayhtml attribute. Thanks for pointing that out.
    I also wrote an article about JavaFX deployment that other readers may find useful:
    http://www.dieajax.com/2008/12/19/10-minute-javafx-tutorial-deploy-javafx-applets-and-applications-both-online-and-offline/

  2. Rakesh Menon says:

    Thanks David. I liked the article. Yes I think we must stress more on javafxpackager utility. Thanks for sharing it.

  3. Greg says:

    <script>
    javafx(
    {
    archive: "JavaFX_Flickr_Image_Viewer.jar",
    draggable: true,
    width: 800,
    height: 650,
    code: "carousel.Main",
    name: "JavaFX_Flickr_Image_Viewer",
    }
    );
    </script>
    The script above will produce an error with IE.
    The trailing comma will cause an error.
    name: "JavaFX_Flickr_Image_Viewer",
    Should be:
    name: "JavaFX_Flickr_Image_Viewer"

  4. Rakesh Menon says:

    Thanks Greg for pointing out. I fixed it. I just removed the line "displayhtml: true" but didn’t remove the "," and also didn’t try in IE.

  5. hi rakesh i converted another demo from flash to JavaFX please see i start working on my small website on which i will post article and demos just for learning purpose.
    i have some questions
    In flash there is function loadLibrary(.swf) that will loadd swf at user request this is very useful function suppose there is a contact link button in website and user is not intererted in viewing that so it is ineffecient to load that jar file can we do that kind of stuff in javafx on user request the demo will be loaded and shown in progress bar..

  6. Rakesh Menon says:

    @Farrukh Your demos look cool! JavaFX does not directly provide loadLibrary like functionality. I tried to get some info from engineers, basically I wanted to explore feasibility of using custom ClassLoaders. But not fully successful yet.

  7. Chunyen Liu says:

    How to provide parameters to run your own JavaFX applet?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: