本文介绍了JxBrowser HEAVYWEIGHT在WINDOW_CLOSE_REQUEST上处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用JxBrowser 6.2的评估许可证。

I'm currently playing around with the Evaluation License for JxBrowser 6.2.

我正在创建BrowserView,如下所示:

I'm creating the BrowserView as follows:

Browser browser = new Browser(BrowserType.HEAVYWEIGHT);
BrowserView browser_view = new BrowserView(browser);

我附加了BrowserView组件,如下所示:

I'm attaching the BrowserView component as follows:

stage.setScene(new Scene(browser_view));

如果浏览器配置为在LIGHTWEIGHT模式下运行,我可以执行:

If the Browser is configured to operate in LIGHTWEIGHT mode, I'm able to execute:

browser_view.getBrowser().dispose();
Platform.exit();

但是,如果将浏览器配置为在HEAVYWEIGHT模式下运行,则应用程序在执行时挂起: / p>

However, if the Browser is configured to operate in HEAVYWEIGHT mode, then the application hangs when executing:

browser_view.getBrowser().dispose();

我可以在日志中看到Dispose消息已被写入,但它看起来好像是JxBrowser Chromium流程从不接收/处理消息。

I can see in the logs that the Dispose message was written, but it appears as though the JxBrowser Chromium processes never receive/process the message.

任何想法?

推荐答案

正如我之前所回答的那样,解决方法是在隐藏(关闭)舞台后处理浏览器。

一个好方法是将这些命令放在停止( ) JavaFX应用程序的方法。

这样就可以关闭窗口(通过单击关闭按钮或通过调用 Platform.exit()以编程方式),浏览器将处置(整个应用程序将完成并退出)。

As answered before me the solution to this is to dispose the browser after the stage has been hidden (closed).
A good approach would be to put those commands on the stop() method of JavaFX Application.
So that either way you close the window (by clicking the close button or programmatically by calling Platform.exit()), the browser will dispose (and the whole application will finish and exit).

类似的东西:

@Override
public void stop() throws Exception {
    stage.hide();
    browser.dispose();
}

这篇关于JxBrowser HEAVYWEIGHT在WINDOW_CLOSE_REQUEST上处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:13