Friday, May 22, 2009

Post JavaFX Applications on Blogger

There are several examples of blogs out there where people post JavaFX examples and applications as part of a blog post.

I wanted to do this on Blogger too but there are some problems with that.

The suggested method to deploy JavaFX applications via a web site is to upload the .jar and use some JavaScript which places an Applet tag into your page.

First problem: You can not upload .jar files to Blogger. (As far as I know).

Second problem: You can not use JavaScript in a blog post. You can add JavaScript to your template but that does not help with JavaFX applications.

I do not have a real solution for the first problem. But you can of course put your .jar on any website you want. I chose my Google Pages account to do so.

For the second problem I used Firebug. With Firebug you can extract the code added to your page by the JavaFX JavaScripts. I then just added this directly to my post which seams to work (well it does if you see Splash at the and of this post).

The code for my Splash example is:

<div id="deployJavaApplet1Overlay" style="background: white none repeat scroll 0% 0%; position: absolute; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; visibility: hidden;">
<table margin="0" padding="0" border="0" height="200" width="200">
<td align="center" valign="middle">
<img imgheight="100" src="" width="100" />
<div id="deployJavaApplet1" style="position: relative; left: 0px;">
<applet archive=",,,,," code="org.jdesktop.applet.util.JNLPAppletLauncher" mayscript="" height="200" width="200">
<param name="subapplet.classname" value="com.sun.javafx.runtime.adapter.Applet">
<param name="MainJavaFXScript" value="eggeral.splash.Main">

Well I don't know which tricks the JavaFX JavaScripts use to get around Browser compatibility problems and alike. So I think this method might not work everywhere.