2 Replies Latest reply: Jun 8, 2011 8:50 AM by 866949 RSS

    Can Eclipse Rich Client Platform embedded javaFX script?

    866949
      My application is based on Eclipse Rich Platform Application (RCP), and rcp includes the SWT_AWT bridge,
      which allows RCPs to integrate Swing components as:

      Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
      java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
      javax.swing.JPanel panel = new javax.swing.JPanel( );
      frame.add(panel)

      First, I create a JavaFX project, where a subclass of the Scene creates, let's look at the code:

      /*
      * Rect.fx
      */

      public class Rect extends Scene {
      init {
      content = [
      Rectangle { width: 200 height: 200 fill: Color.BLUE },
      Text { x: 20 y: 20 content: "Greetings Earthling!" fill: Color.WHITE }
      ]
      }
      public function run(args : String[]) {
           Rect {}
      }
      }

      Then, another Plug-in Project has been created a rich client application, and rcp includes the SWT_AWT bridge,
      which allows RCPs to integrate Swing components as:

      Composite swtAwtComponent = new Composite(parent, SWT.EMBEDDED);
      java.awt.Frame frame = SWT_AWT.new_Frame( swtAwtComponent );
      javax.swing.JPanel panel = new javax.swing.JPanel( );
      frame.add(panel)

      There are two lines to create the JavaFX scene to be loaded into a JFrame:

      String sceneClass = "test.Rect";
      JComponent myScene = SceneToJComponent.loadScene(sceneClass);

      The SceneToJComponent class comes from the JFXtras project.
      Its loadScene() method loads a JavaFX Scene class and returns a JComponent object,
      which can be used as a normal Swing JComponent.

      String sceneClass = "test.Rect"; // the main class of the javafx script
      JComponent theScene = SceneToJComponent.loadScene(sceneClass);

      In Rcp application, when try the load the class, this code compiling,
      running and trowing exceptionon console I have the following error:

      Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jfxtras/scene/SceneToJComponent
      ....

      also if this class is present in the classpath of the java project.



      Then I've tried to place this code in simple java application (not eclipse rcp) and all went ok.


      Has anyone tried to include this code in eclipse rich client platform (rcp)?

      Thanks in advance, Best regards

      Shanti
        • 1. Re: Can Eclipse Rich Client Platform embedded javaFX script?
          Darryl Burke
          863946 wrote:
          JComponent myScene = SceneToJComponent.loadScene(sceneClass);  
          http://download.oracle.com/javafx/2.0/api/javafx/embed/swing/JFXPanel.html

          db
          • 2. Re: Can Eclipse Rich Client Platform embedded javaFX script?
            866949
            I have download Java FX2.0 to emebed a scene in a Swing component inside a view of a rcp application, setting the classpath with jfxrt.jar.


            See the following code:

            ...
                 public void createPartControl(final Composite parent) {
                      
            SwingUtilities.invokeLater(new Runnable() { 
                      public void run() { 
            jfxPanel = new JFXPanel();
            createScene();


            .....


            but my problem is unresolved, the eclipse console shows the following error:

            Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javafx/embed/swing/JFXPanel
                 at test2zero.FxView$1.run(FxView.java:59)
                 at java.awt.event.InvocationEvent.dispatch(Unknown Source)
                 at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
                 at java.awt.EventQueue.access$000(Unknown Source)
                 at java.awt.EventQueue$1.run(Unknown Source)
                 at java.awt.EventQueue$1.run(Unknown Source)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
                 at java.awt.EventQueue.dispatchEvent(Unknown Source)
                 at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
                 at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
                 at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
                 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
                 at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
                 at java.awt.EventDispatchThread.run(Unknown Source)
            Caused by: java.lang.ClassNotFoundException: javafx.embed.swing.JFXPanel
                 at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
                 at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
                 at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
                 at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
                 at java.lang.ClassLoader.loadClass(Unknown Source)

            Has anyone ever tried to integrate javafx in eclipse rcp application ?

            Thanks

            Shanti