Issue
I'm trying to load browser using JavaFX WebEnginge to swing as below
SwingUtilities.invokeLater(() -> InitGUI());
final JFXPanel jfxPanel = new JFXPanel();
panel.add(jfxPanel);
Platform.runLater(() -> {
WebView webView = new WebView();
jfxPanel.setScene(new Scene(webView));
webView.getEngine().load("https://pl.wikipedia.org/wiki/London");
});
Websites shows in my swing application but when I'm moving a mouse on the loaded website IntelliJ throws
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: 'void com.sun.javafx.embed.EmbeddedSceneInterface.mouseEvent(int, int, boolean, boolean, boolean, int, int, int, int, boolean, boolean, boolean, boolean, boolean)'
at javafx.embed.swing.JFXPanel.sendMouseEventToFX(JFXPanel.java:426)
at javafx.embed.swing.JFXPanel.processMouseEvent(JFXPanel.java:465)
at java.desktop/java.awt.Component.processEvent(Component.java:6401)
at java.desktop/java.awt.Container.processEvent(Container.java:2263)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5012)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4919)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEnterExit(Container.java:4691)
at java.desktop/java.awt.LightweightDispatcher.trackMouseEnterExit(Container.java:4677)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4528)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4489)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2764)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4844)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
I should add mouseEventListeners somewhere? Whole GUI is in my Main class, without any buttons, just JLabels and this webView from javaFX. Error occurs only on this webView every time I move mouse/click. Other swing components don't throw anything.
@edit I haven't posted first line of exception
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: 'void com.sun.javafx.embed.EmbeddedSceneInterface.mouseEvent(int, int, boolean, boolean, boolean, int, int, int, int, boolean, boolean, boolean, boolean, boolean)'
Solution
Problem solved
I've added
--module-path /Users/<user>/javafx-sdk-15/lib --add-modules=javafx.controls,javafx.fxml,javafx.web,javafx.swing
in Run>Edit Configurations>VM options
Answered By - Julekk
Answer Checked By - Gilberto Lyons (JavaFixing Admin)