Using JavaFX MenuBar/Menu/MenuItem in a Scene set to a JFXPanel results in a CCE when the menu is to be dropped down. Possibly related bug: http://javafx-jira.kenai.com/browse/RT-11909
Some discussion at
http://forums.oracle.com/forums/thread.jspa?threadID=2245111
http://forums.oracle.com/forums/thread.jspa?threadID=2250678
Stack trace:
java.lang.ClassCastException: com.sun.javafx.tk.quantum.EmbeddedStage cannot be cast to com.sun.javafx.tk.quantum.WindowStage
at com.sun.javafx.tk.quantum.PopupStage.<init>(PopupStage.java:43)
at com.sun.javafx.tk.quantum.QuantumToolkit.createTKPopupStage(QuantumToolkit.java:381)
at javafx.stage.PopupWindow.impl_visibleChanging(PopupWindow.java:244)
at javafx.stage.Window$11.invalidated(Window.java:435)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:57)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:108)
at javafx.stage.Window.setVisible(Window.java:509)
at javafx.stage.PopupWindow.show(PopupWindow.java:205)
at javafx.stage.PopupWindow.show(PopupWindow.java:220)
at javafx.scene.control.ContextMenu.doShow(ContextMenu.java:213)
at javafx.scene.control.ContextMenu.show(ContextMenu.java:192)
at com.sun.javafx.scene.control.skin.MenuButtonSkinBase.show(MenuButtonSkinBase.java:104)
at com.sun.javafx.scene.control.skin.MenuButtonSkinBase.handleControlPropertyChanged(MenuButtonSkinBase.java:132)
at com.sun.javafx.scene.control.skin.SkinBase$3.invalidated(SkinBase.java:216)
at javafx.beans.value.ObservableValueBase.fireValueChangedEvent(ObservableValueBase.java:107)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:58)
at javafx.beans.property.BooleanPropertyBase.access$100(BooleanPropertyBase.java:35)
at javafx.beans.property.BooleanPropertyBase$Listener.invalidated(BooleanPropertyBase.java:214)
at javafx.beans.value.ObservableValueBase.fireValueChangedEvent(ObservableValueBase.java:107)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:58)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:108)
at javafx.scene.control.Menu.setShowing(Menu.java:114)
at javafx.scene.control.Menu.show(Menu.java:261)
at com.sun.javafx.scene.control.skin.MenuBarSkin$5.handle(MenuBarSkin.java:121)
at com.sun.javafx.scene.control.skin.MenuBarSkin$5.handle(MenuBarSkin.java:118)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:59)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at javafx.scene.Scene$11.dispatchEvent(Scene.java:2446)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at javafx.event.Event.fireEventImpl(Event.java:185)
at javafx.event.Event.fireEvent(Event.java:175)
at javafx.scene.Node.fireEvent(Node.java:5514)
at javafx.scene.Scene$MouseHandler.process(Scene.java:2087)
at javafx.scene.Scene$MouseHandler.process(Scene.java:1934)
at javafx.scene.Scene$MouseHandler.access$1000(Scene.java:1906)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1007)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:1553)
at com.sun.javafx.tk.quantum.EmbeddedScene$3.run(EmbeddedScene.java:250)
at com.sun.javafx.application.PlatformImpl$2.run(PlatformImpl.java:65)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$2.run(WinApplication.java:51)
at java.lang.Thread.run(Thread.java:662)
Some discussion at
http://forums.oracle.com/forums/thread.jspa?threadID=2245111
http://forums.oracle.com/forums/thread.jspa?threadID=2250678
Stack trace:
java.lang.ClassCastException: com.sun.javafx.tk.quantum.EmbeddedStage cannot be cast to com.sun.javafx.tk.quantum.WindowStage
at com.sun.javafx.tk.quantum.PopupStage.<init>(PopupStage.java:43)
at com.sun.javafx.tk.quantum.QuantumToolkit.createTKPopupStage(QuantumToolkit.java:381)
at javafx.stage.PopupWindow.impl_visibleChanging(PopupWindow.java:244)
at javafx.stage.Window$11.invalidated(Window.java:435)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:57)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:108)
at javafx.stage.Window.setVisible(Window.java:509)
at javafx.stage.PopupWindow.show(PopupWindow.java:205)
at javafx.stage.PopupWindow.show(PopupWindow.java:220)
at javafx.scene.control.ContextMenu.doShow(ContextMenu.java:213)
at javafx.scene.control.ContextMenu.show(ContextMenu.java:192)
at com.sun.javafx.scene.control.skin.MenuButtonSkinBase.show(MenuButtonSkinBase.java:104)
at com.sun.javafx.scene.control.skin.MenuButtonSkinBase.handleControlPropertyChanged(MenuButtonSkinBase.java:132)
at com.sun.javafx.scene.control.skin.SkinBase$3.invalidated(SkinBase.java:216)
at javafx.beans.value.ObservableValueBase.fireValueChangedEvent(ObservableValueBase.java:107)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:58)
at javafx.beans.property.BooleanPropertyBase.access$100(BooleanPropertyBase.java:35)
at javafx.beans.property.BooleanPropertyBase$Listener.invalidated(BooleanPropertyBase.java:214)
at javafx.beans.value.ObservableValueBase.fireValueChangedEvent(ObservableValueBase.java:107)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:58)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:108)
at javafx.scene.control.Menu.setShowing(Menu.java:114)
at javafx.scene.control.Menu.show(Menu.java:261)
at com.sun.javafx.scene.control.skin.MenuBarSkin$5.handle(MenuBarSkin.java:121)
at com.sun.javafx.scene.control.skin.MenuBarSkin$5.handle(MenuBarSkin.java:118)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:59)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:161)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at javafx.scene.Node$19.dispatchEvent(Node.java:5409)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
at javafx.scene.Scene$11.dispatchEvent(Scene.java:2446)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at javafx.event.Event.fireEventImpl(Event.java:185)
at javafx.event.Event.fireEvent(Event.java:175)
at javafx.scene.Node.fireEvent(Node.java:5514)
at javafx.scene.Scene$MouseHandler.process(Scene.java:2087)
at javafx.scene.Scene$MouseHandler.process(Scene.java:1934)
at javafx.scene.Scene$MouseHandler.access$1000(Scene.java:1906)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1007)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:1553)
at com.sun.javafx.tk.quantum.EmbeddedScene$3.run(EmbeddedScene.java:250)
at com.sun.javafx.application.PlatformImpl$2.run(PlatformImpl.java:65)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$2.run(WinApplication.java:51)
at java.lang.Thread.run(Thread.java:662)