JxBrowser HEAVYWEIGHT Dispose on WINDOW_CLOSE_REQUEST

╄→尐↘猪︶ㄣ 提交于 2019-12-07 12:31:42

问题


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

I'm creating the BrowserView as follows:

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

I'm attaching the BrowserView component as follows:

stage.setScene(new Scene(browser_view));

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

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

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

browser_view.getBrowser().dispose();

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.

Any ideas?


回答1:


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).

Something like that:

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



回答2:


As a reference, I used configuration described here link (Section: 9. Pop-up Windows).

Platform.runLater(() -> {
    browser.dispose();
});

Platform.runLater(() -> {
    stage.close();
});



回答3:


It looks like you need to ensure that the stage has been closed before calling dispose.

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



回答4:


Please try calling this code asynchronously. Maybe it's just a deadlock:

Platform.runLater(new Runnable() {
    @Override
    public void run() {
        browser_view.getBrowser().dispose();
        Platform.exit();
    }
});


来源:https://stackoverflow.com/questions/35820197/jxbrowser-heavyweight-dispose-on-window-close-request

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!