【发布时间】:2021-02-28 03:10:54
【问题描述】:
我尝试在我的 java 项目中使用 WebView,在我的代码中是:
JFXPanel fxPanel = new JFXPanel();
fxPanel.setBounds(10, 48, 439, 362);
desktopPane.add(fxPanel);
WebView webView = new WebView();
fxPanel.setScene(new Scene(webView));
webView.getEngine().load("http://www.stackoverflow.com/");
但是这抛出了一个异常
java.lang.IllegalStateException: Not on FX application thread; currentThread = main
是的,这不是 JavaFx 应用程序。
【问题讨论】:
-
如果这不是 JavaFX 应用程序,您为什么要使用它?
-
我喜欢在我的应用程序中加载网站(html5 和 css 支持):) JEditorPane 不支持 html5 :(