0

I am trying to integrate JavaFX in an existing Swing application. I am following this tutorial, so before actually integrating it into the existing application, I can have an environment with reduced complexity and try if it is working before moving further. I was following the tutorial at the official website of Oracle/JavaFX at http://docs.oracle.com/javafx/2/swing/swing-fx-interoperability.htm . Especially, I was also downloading the source code of the example SwingInterop.zip and still getting the same exception:

run:

    Exception in thread "Thread-1" java.lang.UnsatisfiedLinkError: com.sun.glass.ui.win.WinApplication._submitForLaterInvocation(Ljava/lang/Runnable;)V
    at com.sun.glass.ui.win.WinApplication._submitForLaterInvocation(Native Method)
    at com.sun.glass.ui.win.WinApplication.submitForLaterInvocation(WinApplication.java:215)
    at com.sun.glass.ui.InvokeLaterDispatcher.run(InvokeLaterDispatcher.java:101)

I've found a thread in StackOverflow (UnsatisfiedLinkError when running mvn jfx:run with IntelliJ) which might be the one I'm looking for. Is this what I need to do? I tried but it didn't work, probably because I did not do it properly?

It has to do with performing the operation in the correct thread,because as far as I understand Swing and JavaFX are running in two different threads: the portion of code (which is the one in the example, not even written by me) which leeds to this issue might be :

@Override
public void init() {
    tableModel = new JTableDataInOut();
    // create javafx panel for charts
    chartFxPanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, PANEL_HEIGHT_INT));

    //create JTable
    JTable table = new JTable(tableModel);
    table.setAutoCreateRowSorter(true);
    table.setGridColor(Color.DARK_GRAY);
    SwingInterop.DecimalFormatRenderer renderer
            = new SwingInterop.DecimalFormatRenderer();
    renderer.setHorizontalAlignment(JLabel.RIGHT);
    for (int i = 0; i < table.getColumnCount(); i++) {
        table.getColumnModel().getColumn(i).setCellRenderer(renderer);
    }
    JScrollPane tablePanel = new JScrollPane(table);
    tablePanel.setPreferredSize(new Dimension(PANEL_WIDTH_INT, TABLE_PANEL_HEIGHT_INT));
    JPanel chartTablePanel = new JPanel();
    chartTablePanel.setLayout(new BorderLayout());

    //Create split pane that holds both the bar chart and table
    JSplitPane jsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    jsplitPane.setTopComponent(chartTablePanel);
    jsplitPane.setBottomComponent(tablePanel);
    jsplitPane.setDividerLocation(410);
    chartTablePanel.add(chartFxPanel, BorderLayout.CENTER);

    //Add the split pane to the content pane of the application
    add(jsplitPane, BorderLayout.CENTER);

    Platform.runLater(new Runnable() {

        @Override
        public void run() {
            BarChart chart = createBarChart();
            chartFxPanel.setScene(new Scene(chart));
        }
    });
}
Community
  • 1
  • 1
  • I also needed to integrate JavaFX into my application, and I followed [this](http://marxsoftware.blogspot.com/2011/12/integrating-javafx-20-with-swing-and.html) guide on how to do so. That seems a lot simpler than Oracle's article. –  Jan 21 '14 at 12:51
  • Thank you Hassan, actually I think my problem is related to the correct configuration of the CLASSPATH such things. I keep getting the error even though the code is working properly. I think I am missing some kind of import (I have jfxrt.jar in my classpath, but still not working) – gigi lacremeria Jan 21 '14 at 14:04
  • Kind of a long shot, but are you sure you're using a Java 1.7 compiler and JRE? JavaFX doesn't seem to be compatible with 1.6. –  Jan 21 '14 at 14:40
  • C:\Users\...\Documents\NetBeansProjects\AIDMT\src>java -version java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode) – gigi lacremeria Jan 21 '14 at 14:42
  • Thanks for the suggestion...I checked and it should be Java 1.7; – gigi lacremeria Jan 21 '14 at 14:43
  • Not sure what is happening here. I was checking this post on StackOverflow : http://stackoverflow.com/questions/10888367/compiling-and-running-with-javafx-2-1 and compiling and running the simple example worked from command line (msdos) following the instructions on the post I cited above. But when trying to run it under Netbeans 7.4 still get the exception, and still haven't figured out how to correctly manage the dependencies! still not working... – gigi lacremeria Jan 21 '14 at 14:55
  • That certainly is strange. When I tried it, I used Eclipse, so I don't know about Netbeans-specific settings. –  Jan 21 '14 at 15:54
  • OK thanks for giving it a try...I still don't get how it needs to be configured! can you provide an example of your CLASSPATH , JAVA_HOME and eclipse settings? Thank you for your time – gigi lacremeria Jan 21 '14 at 16:38
  • I'm not 100% sure how to get those. On Eclipse, all I did was I added jfxrt.jar to my build path, then downloaded and installed Java 1.7. In the Eclipse settings, I went to Java -> Installed JRE, and clicked "Add" to add the path to the copy of Java that I just installed. I also went to my project's compile settings and changed the compiler "compliance level" to 1.7. –  Jan 21 '14 at 17:21

0 Answers0