« Slides from JavaPolis 2007 JavaFX Script in Action "University Session" | Main | Spotting JavaFX Apps in the Wild - Santa's Super Status System »

December 23, 2007

Comments

Jim Weaver

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.

Eric Love

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.

Jim Weaver

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


Eric Love

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

The comments to this entry are closed.

Categories