javafx WebView无法加载HTML文件

时间:2017-10-12 05:28:51

标签: html javafx webview proxy

我有一个WebView对象试图上传一个HTML文件,但它无法正常工作,窗口保持白色...我读到可能是代理设置但我不知道(如果是那样)怎么样改变他们。你能帮帮我吗?

public class MainPluginApplication extends Application {

Pane rootLayout;

public static void main(String[] args) {
    launch(args);
}

@Override
public void start(Stage stage) {

    stage.setTitle("beans.DiagramTask Drawing");

    WebView browser = new WebView();
    WebEngine engine = browser.getEngine();
    String url = getClass().getResource("./controller/diagramTree.html").toExternalForm();
    engine.load(url);

    StackPane sp = new StackPane();
    sp.getChildren().add(browser);

    Scene scene = new Scene(sp);
    stage.setScene(scene);

    stage.show();
}

HTML:

<html>
<head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
        google.charts.load('current', {packages:["orgchart"]});
        google.charts.setOnLoadCallback(drawChart);

    function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('string', 'Manager');
        data.addColumn('string', 'ToolTip');

        // For each orgchart box, provide the name, manager, and tooltip to show.
        data.addRows([
            [{v:'Mike', f:'Mike<div style="color:red; font-style:italic">President</div>'},
                '', 'The President'],
            [{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'},
                'Mike', 'VP'],
            ['Alice', 'Mike', ''],
            ['Bob', 'Jim', 'Bob Sponge'],
            ['Carol', 'Bob', '']
        ]);

        // Create the chart.
        var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
        // Draw the chart, setting the allowHtml option to true for the tooltips.
        chart.draw(data, {allowHtml:true});
    }
    </script>
</head>
<body>
<div id="chart_div"></div>
</body>
</html>

我听说可能会做这样的事情::

System.getProperties().put("http.proxyHost", "ProxyURL");
System.getProperties().put("http.proxyPort", "ProxyPort");
System.getProperties().put("http.proxyUser", "UserName");
System.getProperties().put("http.proxyPassword", "Password");

但我不知道要放置什么代理主​​机和端口

0 个答案:

没有答案