Hi all,

I am using JFxPanel to embed JavaFx into Swing. I occasionally get a NullPointerException with the following stack trace:

Java FX Code:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at javafx.embed.swing.JFXPanel$HostContainer$1.run(JFXPanel.java:741)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:312)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
	at java.awt.EventQueue.access$200(EventQueue.java:103)
	at java.awt.EventQueue$3.run(EventQueue.java:694)
	at java.awt.EventQueue$3.run(EventQueue.java:692)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
I create my swing components on the EDT and my JavaFx components on the JavaFx app thread like this:

Java FX Code:
SwingUtilities.invokeLater(new Runnable {
    JFXPanel panel = new Panel();

    Platform.runLater(new Runnable {
        @Override public void run(): Unit = {
            Scene scene = new Scene(parent);
            panel.setScene(scene);
        }
    })
})
From searching around, it appears that 'scenePeer ' is sometimes null in the panel. It also sounds like this is fixed in JavaFx 8, but this is not an option for me.
I also tried implementing an 'invokeAndWait' using runLater and a countdown latch to make sure the scene was created before continuing on the EDT. This did not help.

Can anyone tell me how to fix this?

Thanks in advance.