To wish you Happy Holidays (and if you'll permit me, a very merry Christmas) I wrote this Compiled JavaFX Script Applet (that executes in a browser).
For fast deployment I used the latest version of Java SE 6 Update 10 (formerly known as Java SE Update N, formerly known as Consumer JRE, formerly known as Prince :-D). I also used the latest beta version of Firefox (Minefield 3.0 beta), as this is necessary if you want to use the Java SE Update 10 browser plug-in with Firefox. Check out this video blog by Robert Eckstein for some great information about Java SE Update 10.
The JavaFX Script compiler team is working as we speak on a simple, elegant, way to create JavaFX Applets. The technique that I used is a short term approach that should not be used as a model for creating JavaFX Script applets beyond just playing around.
Update March 16, 2008: There are two ways to create JavaFX Script applets, described in detail in the following posts:
- Creating Compiled JavaFX Applets - Method One (of Two)
- Creating Compiled JavaFX Script Applets - Method Two
Happy Holidays,
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
eBook (PDF) download immediately available at the book's Apress site
Today applets cannot subclass javafx.ui.Applet, which they should (just like Swing applets should subclass JApplet). This should be fixed soon, and I'll make a post as soon as that happens. It's probably just a side effect from how compiled JavaFX Script maps classes which use multiple inheritance to Java single inheritance, and should be fixed soon.
Posted by: Jim Weaver | January 04, 2008 at 08:51 AM
Hello Jim,
I can't wait until your blog comes out concerning JavaFX Applets. Also, thanks for providing information on JavaFX Apps deployment using JNLP in your blog. Great and very useful information.
Posted by: Eric Love | January 03, 2008 at 03:01 PM
Eric,
Thanks for your kind words about my book. A member of the JavaFX Script Compiler team worked over the Christmas holiday on a simple, elegant, way to create JavaFX Applets. This effort is almost finished, and as soon as it is, I'll blog about it. In the meantime, as I promised, here is the code that I used to create this example. Please remember that it uses compiled JavaFX Script, and that it shouldn't be used as a basis for creating JavaFX Applets other than just playing around. A more elegant solution is coming soon.
// AppletStub.java
package jfxapplet;
import javax.swing.JApplet;
public class AppletStub extends JApplet { }
/*
* HappyHolidaysAppletJFX.fx - A Compiled JavaFX Script applet example
*
*
* Developed 2007 by James L. Weaver (jim.weaver at lat-inc dot com)
* to serve as a JavaFX Script example. This particular example shows
* a technique for dislaying applets that will be improved upon by the
* JavaFX compiler team, but it works for now.
*/
package jfxapplet;
import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.System;
import jfxapplet.AppletStub;
public class HappyHolidaysAppletJFX extends AppletStub {
public function >():Void {
var message:String = "Happy Holidays";
var messageOpa:Integer = 0;
var panel =
BorderPanel {
border:
TitledBorder {
title: "Happy Holidays JavaFX Applet"
}
top:
FlowPanel {
content: [
Button {
text: "Happy Holidays"
action:
function() {
messageOpa = if (messageOpa == 0) 1 else 0;
}
}
]
}
center:
Canvas {
content:
Group {
content: [
ImageView {
image:
Image {
url: "https://duke.dev.java.net/images/misc/SantaDuke.png"
}
opacity: bind 1 - messageOpa * .2
},
Text {
font:
Font {
faceName: "Palace Script MT"
style: FontStyle.PLAIN
size: 80
}
stroke: Color.RED
fill: Color.RED
x: 60
y: 300
content: bind message
opacity: bind messageOpa
}
]
}
}
};
setContentPane(panel.getComponent());
}
}
// HappyHolidaysAppletPage.html
Posted by: Jim Weaver | December 28, 2007 at 04:43 PM
I just got your book on JavaFX Script. It is great. I was wondering if JFX can be used to create applets. Fom your blog, I guess it can be done. I would like to your code JFX Applet.
Thanks,
Eric
Posted by: Eric Love | December 28, 2007 at 02:56 PM