Search in sources :

Example 1 with DownloadHandler

use of com.teamdev.jxbrowser.chromium.DownloadHandler in project TeachingInSimulation by ScOrPiOzzy.

the class TestJxBrowserPdf method start.

@Override
public void start(Stage primaryStage) throws Exception {
    primaryStage.initStyle(StageStyle.TRANSPARENT);
    Browser browser = new Browser(BrowserType.LIGHTWEIGHT);
    BrowserView view = new BrowserView(browser);
    primaryStage.setScene(new Scene(view));
    browser.loadURL("http://192.168.1.19:8082/Test/Fanuc0i参数说明书.pdf");
    // browser.executeJavaScript("var child=document.getElementById(\\\"download\\\");child.parentNode.removeChild(child);");
    // browser.executeJavaScript("alert(document.getElementById('download'))");
    browser.setDownloadHandler(new DownloadHandler() {

        @Override
        public boolean allowDownload(DownloadItem download) {
            System.out.println(download.getURL());
            return false;
        }
    });
    primaryStage.show();
}
Also used : DownloadHandler(com.teamdev.jxbrowser.chromium.DownloadHandler) BrowserView(com.teamdev.jxbrowser.chromium.javafx.BrowserView) DownloadItem(com.teamdev.jxbrowser.chromium.DownloadItem) Scene(javafx.scene.Scene) Browser(com.teamdev.jxbrowser.chromium.Browser)

Aggregations

Browser (com.teamdev.jxbrowser.chromium.Browser)1 DownloadHandler (com.teamdev.jxbrowser.chromium.DownloadHandler)1 DownloadItem (com.teamdev.jxbrowser.chromium.DownloadItem)1 BrowserView (com.teamdev.jxbrowser.chromium.javafx.BrowserView)1 Scene (javafx.scene.Scene)1