jxbrowser java代码直接调用js代码

https://blog.csdn.net/shuaizai88/article/details/73743669

final Browser browser = new Browser();
        BrowserView browserView = new BrowserView(browser);
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(browserView, BorderLayout.CENTER);
        frame.setSize(700, 500);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        browser.addLoadListener(new LoadAdapter() {
            @Override
            public void onFinishLoadingFrame(FinishLoadingEvent event) {
                if (event.isMainFrame()) {
                    browser.executeJavaScript("alert('java調用了js')");
                }
            }
        });
        browser.loadURL("E:/workspace48/browser/test.html");

 

posted @ 2019-04-30 14:02  tc310  阅读(717)  评论(0编辑  收藏  举报