The PopupMenuImpl needs a Group node as WebView parent node. If other nodes used, a CCE is thrown on right mouse click:
java.lang.ClassCastException: javafx.scene.layout.VBox cannot be cast to javafx.scene.Group
at com.sun.webpane.sg.theme.PopupMenuImpl.doShow(PopupMenuImpl.java:104)
at com.sun.webpane.sg.theme.ContextMenuImpl.show(ContextMenuImpl.java:62)
at com.sun.webpane.platform.ContextMenu.fwkShow(ContextMenu.java:40)
at com.sun.webpane.platform.WebPage.twkProcessMouseEvent(Native Method)
at com.sun.webpane.platform.WebPage.dispatchMouseEvent(WebPage.java:675)
at javafx.scene.web.WebView.processMouseEvent(WebView.java:366)
at javafx.scene.web.WebView.access$100(WebView.java:41)
at javafx.scene.web.WebView$2.handle(WebView.java:396)
at javafx.scene.web.WebView$2.handle(WebView.java:394)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:55)
at com.sun.javafx.event.DefaultEventDispatcher.dispatchBubblingEvent(DefaultEventDispatcher.java:173)
at com.sun.javafx.event.DefaultEventDispatcher.dispatchBubblingEvent(DefaultEventDispatcher.java:157)
at com.sun.javafx.event.DefaultEventDispatcher.dispatchEvent(DefaultEventDispatcher.java:120)
at javafx.scene.Node$7.dispatchEvent(Node.java:3863)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventRedirector.dispatchEvent(EventRedirector.java:79)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at javafx.event.Event.fireEventImpl(Event.java:172)
at javafx.event.Event.fireEvent(Event.java:162)
at javafx.scene.Node.fireEvent(Node.java:3968)
at javafx.scene.Scene$MouseHandler.process(Scene.java:1912)
at javafx.scene.Scene$MouseHandler.process(Scene.java:1753)
at javafx.scene.Scene$MouseHandler.access$600(Scene.java:1725)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:882)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:1380)
at com.sun.javafx.tk.glass.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:93)
at com.sun.glass.ui.View.handleMouseEvent(View.java:259)
at com.sun.glass.ui.View.notifyMouse(View.java:498)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:14)
at com.sun.glass.ui.win.WinApplication$1.run(WinApplication.java:33)
at java.lang.Thread.run(Thread.java:662)
Code snippet:
Scene scene = new Scene(vbox = new VBox());
webEngine = new WebEngine();
webView = new WebView(webEngine);
vbox.getChildren().add (webView);
HTMLDocument doc = (HTMLDocument) webEngine.getDocument();
Element html = (Element) doc.getElementsByTagName("html").item(0);
Element head = doc.createElement("head");
html.appendChild(head);
Element body = doc.createElement("body");
html.appendChild(body);
Element text = doc.createElement("p");
text.setTextContent("Please click with your right mouse button");
body.appendChild(text);
primaryStage.setScene(scene);
br, josh.
java.lang.ClassCastException: javafx.scene.layout.VBox cannot be cast to javafx.scene.Group
at com.sun.webpane.sg.theme.PopupMenuImpl.doShow(PopupMenuImpl.java:104)
at com.sun.webpane.sg.theme.ContextMenuImpl.show(ContextMenuImpl.java:62)
at com.sun.webpane.platform.ContextMenu.fwkShow(ContextMenu.java:40)
at com.sun.webpane.platform.WebPage.twkProcessMouseEvent(Native Method)
at com.sun.webpane.platform.WebPage.dispatchMouseEvent(WebPage.java:675)
at javafx.scene.web.WebView.processMouseEvent(WebView.java:366)
at javafx.scene.web.WebView.access$100(WebView.java:41)
at javafx.scene.web.WebView$2.handle(WebView.java:396)
at javafx.scene.web.WebView$2.handle(WebView.java:394)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:55)
at com.sun.javafx.event.DefaultEventDispatcher.dispatchBubblingEvent(DefaultEventDispatcher.java:173)
at com.sun.javafx.event.DefaultEventDispatcher.dispatchBubblingEvent(DefaultEventDispatcher.java:157)
at com.sun.javafx.event.DefaultEventDispatcher.dispatchEvent(DefaultEventDispatcher.java:120)
at javafx.scene.Node$7.dispatchEvent(Node.java:3863)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at com.sun.javafx.event.EventRedirector.dispatchEvent(EventRedirector.java:79)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
at javafx.event.Event.fireEventImpl(Event.java:172)
at javafx.event.Event.fireEvent(Event.java:162)
at javafx.scene.Node.fireEvent(Node.java:3968)
at javafx.scene.Scene$MouseHandler.process(Scene.java:1912)
at javafx.scene.Scene$MouseHandler.process(Scene.java:1753)
at javafx.scene.Scene$MouseHandler.access$600(Scene.java:1725)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:882)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:1380)
at com.sun.javafx.tk.glass.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:93)
at com.sun.glass.ui.View.handleMouseEvent(View.java:259)
at com.sun.glass.ui.View.notifyMouse(View.java:498)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:14)
at com.sun.glass.ui.win.WinApplication$1.run(WinApplication.java:33)
at java.lang.Thread.run(Thread.java:662)
Code snippet:
Scene scene = new Scene(vbox = new VBox());
webEngine = new WebEngine();
webView = new WebView(webEngine);
vbox.getChildren().add (webView);
HTMLDocument doc = (HTMLDocument) webEngine.getDocument();
Element html = (Element) doc.getElementsByTagName("html").item(0);
Element head = doc.createElement("head");
html.appendChild(head);
Element body = doc.createElement("body");
html.appendChild(body);
Element text = doc.createElement("p");
text.setTextContent("Please click with your right mouse button");
body.appendChild(text);
primaryStage.setScene(scene);
br, josh.