0

I have a Swing application in which I need to display internally generated HTML/CSS. In order to do this, I have adapted the code from this StackOverflow question.

The control works fine. However, when the application ends, I receive the error

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f9622171ae8, pid=5782, tid=140283095549696

For what it's worth, the sample code directly from Oracle (quoted in the StackOverflow post) has the same problem.

I have tried explicitly calling Platform.exit() when the window closes, but the error remains. So, how does one shut down JavaFX correctly, when it is embedded in a Swing application?

4

1 回答 1

2

好的,我找到了解决方案,至少对于这个应用程序:

  • 这是一个多窗口应用程序;JavaFX 组件不在主应用程序窗口中,而是在子窗口中。

  • JavaFX“平台”有一个设置“ImplicitExit”,默认为“true”。

  • JavaFX Platform.exit() 显然在子窗口关闭时和主应用程序关闭时都被调用。第二次调用(当应用程序关闭时)生成原始问题中描述的错误消息。

  • “隐式退出”行为在任何情况下都是不可取的,因为它会阻止子窗口在应用程序的生命周期内第二次重新打开。

因此,解决方案是关闭“隐式退出”。这是子窗口中的 JavaFX 初始化代码:

Platform.runLater(new Runnable() {
    @Override public void run() {
        view = new WebView();
        engine = view.getEngine();
        jfxPanel.setScene(new Scene(view));
        Platform.setImplicitExit(false); // Otherwise cannot open report window a second time
    }
});
于 2013-08-31T06:33:25.343 回答