Posted by jimaltio
on May 18, 2008 at 5:55 AM PDT
I have an existing Swing applet that I'm trying to add JavaFX support to.
I already have it working with interpreted JavaFX, via the Java6 Scripting Engine and adding the JavaFX Canvas's component to a JPanel, and that's fine for simple scripts, but for better performance and a simple way to deploy and run multi-script JavaFX code I'd like to use compiled JavaFX as well.
I have a JavaFX script that defines a class, which I instantiate from my Swing applet via reflection - that works fine. I then call a method on the class to return a JComponent to me so that I can add it to my Swing UI, and that's where the problem starts.
I intended to have the JavaFX class return the result of the Canvas.getComponent() method but I cannot create a Canvas object from within my compiled JavaFX class. At runtime I see the following Exception;
Caused by: java.lang.NoSuchMethodError: javafx.ui.Canvas.(Z)V
My JavaFX code for creating a Canvas (and also Frame, Text or FlowPanel I have discovered) which works fine when I run the compiled JavaFX file from the command-line, does not work at runtime in the Swing applet.
Is this some kind of Applet sandbox permission issue, or something simpler? I am running the applet via a JNLP file, and including the javafxrt.jar and scenario.jar files, so everything is hooked up correctly and I'm at a loss to figure out what's going on.
Any help would be appreciated.