隐藏阶段时 JxBrowser 视图消失

JxBrowser view is gone when stage is hidden

我在我的 javafx 应用程序中使用了 jxbrowser :

public class Main extends Application {

private Stage primaryStage;

private Browser browser;

private boolean firstMinimize;

private TrayIcon trayIcon;

public static void main(String[] args) {

    launch(args);

}

@Override
public void start(Stage primaryStage) {

    this.primaryStage = primaryStage;

    firstMinimize = true;

    Platform.setImplicitExit(false);

    createTrayIcon();

    browser = new Browser();

    BrowserView browserView = new BrowserView(browser);

    StackPane pane = new StackPane();

    pane.getChildren().add(browserView);

    Scene scene = new Scene(pane, 380, 500);

    primaryStage.initStyle(StageStyle.UNDECORATED);

    primaryStage.setScene(scene);

    primaryStage.show();

    browser.addRenderListener(new RenderAdapter() {
        @Override
        public void onRenderGone(RenderEvent event) {

            System.out.println("here called...");

            Browser browser = event.getBrowser();
            // Restore Browser instance by loading the same URL
            browser.loadURL(browser.getURL());
        }
    });

    initialize();

    // if not logged in

    showLogin();

}

public void initialize() {

    initCloseButton(primaryStage);

    initMinimizeButton(primaryStage);

}

public void initCloseButton(Stage primaryStage) {

    browser.registerFunction("Close", new BrowserFunction() {

        @Override
        public JSValue invoke(JSValue... args) {

            Platform.runLater(new Runnable() {

                @Override
                public void run() {

                    closeToTray(primaryStage);

                }
            });

            return null;

        }

    });

}

public void initMinimizeButton(Stage primaryStage) {

    browser.registerFunction("Minimize", new BrowserFunction() {

        @Override
        public JSValue invoke(JSValue... args) {

            Platform.runLater(new Runnable() {

                @Override
                public void run() {

                    primaryStage.setIconified(true);

                }
            });

            return null;

        }

    });

}


public void createTrayIcon() {

    if (SystemTray.isSupported()) {

        SystemTray tray = SystemTray.getSystemTray();

        java.awt.Image image = null;

        try {

            URL url = new URL("http://www.digitalphotoartistry.com/rose1.jpg");

            image = ImageIO.read(url);

        } catch (IOException ex) {

            System.out.println(ex);

        }


        final ActionListener closeListener = new ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {

                System.exit(0);

            }

        };

        final ActionListener showListener = new ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {

                Platform.runLater(new Runnable() {

                    @Override
                    public void run() {

      //                            primaryStage.setOpacity(0);

                        primaryStage.show();

                    }

                });

            }

        };

        PopupMenu popup = new PopupMenu();

        MenuItem showItem = new MenuItem("Show");
        showItem.addActionListener(showListener);
        popup.add(showItem);

        MenuItem closeItem = new MenuItem("Close");
        closeItem.addActionListener(closeListener);
        popup.add(closeItem);

        trayIcon = new TrayIcon(image, "RezRem", popup);

        trayIcon.addActionListener(showListener);

        try {

            tray.add(trayIcon);

        } catch (AWTException e) {

            System.err.println(e);

        }

    }

}

public void showMinimizeMessage() {

    if (firstMinimize) {

        trayIcon.displayMessage("some message",
                "Some other message.",
                TrayIcon.MessageType.INFO);

        firstMinimize = false;

    }

}

private void closeToTray(Stage primaryStage) {

    Platform.runLater(new Runnable() {

        @Override

        public void run() {

            if (SystemTray.isSupported()) {

     //                 primaryStage.setOpacity(0);

                primaryStage.hide();

                showMinimizeMessage();

            } 
            else {

                System.exit(0);

            }

        }
    });
}

public void showLogin() {

    browser.loadURL(Main.class.getResource("templates/login.html").toExternalForm());

    browser.registerFunction("Login", new BrowserFunction() {

        @Override
        public JSValue invoke(JSValue... args) {

            for (JSValue arg : args) {

                System.out.println("arg = " + arg.getString());

            }

            return JSValue.create("Hello!");

        }

    });

}

}

我已将关闭按钮设置为在函数 "closeToTray" 中单击时隐藏舞台。(以便将其最小化到系统托盘)但是随后调用 stage.show() 会打开浏览器但浏览器视图只是整体变白了,换句话说,渲染的页面就这么走了。这是最小化到系统托盘之前和之后的屏幕截图: Before clicking close btn, after clicking show from system tray

有什么想法吗?

提前致谢

这是 JxBrowser 6.0.2 中的一个已知问题。该修复程序将在一周后发布的下一个更新中提供。