Applet and JavaFX and Confusion
Friday Jul 11, 2008
Two weeks back in BOJUG meeting, I have seen lot many engineers getting confuse with JavaFX. They want to know how to run FX code in browser. Shall we use applet to run FX code. And many more. Though it tough to explain everything in a small presentation but Harish Singh and we have tried our best to explain some of the queries. Yes, FX can be very well run in an applet. I have written one HelloWorld type of example for running FX code inside applet. Its very well same. *.fx file create a .class file and then handling in the same way as we do with .class file.
Here is a small code for "My Hello World" (HelloApplet.fx)
import javafx.ui.*;
Applet{
content: Label {
text: "My Hello world!"
}
}
Now you have to compile this with javafxc, so that we can use class file. For that you need to download javafx compiler, runtime and some more jars. From this link you can download it.
Now here is little tough part, making html file for applet :-). Tough because you get to know which jar files your code is using. And you will not get documents readily to say you which API belong to which package + API's in themselves are changing. So, you may not able to run your older codes. Anyway, I have written this html code(Hello.html):
<html> <body> <applet code="javafx.ui.Applet" width=480 height=560 archive="javafxrt.jar, Scenario.jar, javafxgui.jar, javafxc.jar, javafx-swing.jar, javafx.jar"> <param name="AppletClass" value="HelloApplet"> </applet> </body> </html>Don't ask me why I have added some many archive. I got frustrated in knowing what residing where. And so, I have ended up adding all the jar that I have seen in the archive(in the link) :). Check it out, let me know if there exist any problem.
Surprisingly you can call Frame also from applet, check this code:
import javafx.ui.*;
Frame {
title: "Hello World F3"
width: 200
content: Label {
text: "Hello World"
}
visible: true
}
In the next blog I will also cover some other way to use on web. 














As far as I am concerned, Netbeans plugin should h...
Probably Yes !
Hi Vaibhav,
I read your blog describing JAVAFX. Th...
Yes we can. Only thing in which we are laggin...
Hi vaibhav,
well vaibhav can give me some site exa...
there are some undergoing. Frankly its not very st...
Hi vaibhav,
Thanks for your blog,I learn a lot fro...