Createing ContextMenu outside of FX thread
Werner Lehmann
lehmann at media-interactive.de
Tue Apr 24 10:11:46 PDT 2012
Hi,
I just noticed that I cannot create a ContextMenu in the Swing EDT. The
following fails in the build method:
ContextMenu cm = ContextMenuBuilder.create()
.items(
new MenuItem("item"))
.build();
I was under the impression that adding to a scene graph must be done in
the FX thread but I am not doing that here. Although the trace says
different:
> Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Not on FX application thread; currentThread = AWT-EventQueue-0
> at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:235)
> at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:393)
> at javafx.scene.Scene.<init>(Scene.java:265)
> at javafx.scene.Scene.<init>(Scene.java:177)
> at javafx.stage.PopupWindow.<init>(PopupWindow.java:102)
> at javafx.scene.control.PopupControl.<init>(PopupControl.java:101)
> at javafx.scene.control.ContextMenu.<init>(ContextMenu.java:129)
> at javafx.scene.control.ContextMenuBuilder.build(ContextMenuBuilder.java:75)
So, I expected that setting the contextmenu on a button or something
which was already part of a scene would require the FX thread context -
but not building it. Is ContextMenu special because it is a PopupWindow
and not a Node, or is this a misconception on my part?
Werner
More information about the openjfx-dev
mailing list