Question

I am writing a NetBeans plugin which requires some graphs. I am seeing a NullPointer exception when I embed a JavaFX chart into a TopComponent. When I maximize any other TopComponent I have created for my plugin, I see the following exception:

java.lang.NullPointerException
   at javafx.embed.swing.JFXPanel$HostContainer$1.run(Unknown Source)
   at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
   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 org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
[catch] 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)

The plugin still runs and there seems to be nothing else wrong other than this exception popping up. The TopComponent is registered with

@TopComponent.Registration(mode = "commonpalette", openAtStartup = true)

and the persistence type persistenceType = TopComponent.PERSISTENCE_NEVER

I am creating the chart with

Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
        @Override
        public void run() {
            //creating scene here <other code>
            myPanel.setScene(scene);
        }
   });

and then adding it to a GroupLayout straight onto the TopComponent

this.setLayout(layout);
//then adding myPanel to the layout

If it is also of note, I see this error a lot too

Dangerous reflection access to sun.misc.SharedSecrets by class com.sun.javafx.tk.quantum.QuantumToolkit$17 detected!
code location: jar:file:/C:/<my_plugin>/build/cluster/modules/ext/jfxrt.jar!/

but have been led to believe I can ignore this?

Has anyone else come across this before or can see what is going wrong? I have tried other layouts, detecting when the JavaFX panel has been removed and haven't found a solution yet. Any suggestions would be much appreciated :)

For reference, my JavaFX version is 2.2.45 with the NetBeans IDE up to date.

Thanks

Was it helpful?

Solution

Solved this in the end, it involved listening for when the topcomponent's jpanel became null, then removing the javafx panel, readding later when it was shown.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top