JavaFX刷新webview

时间:2015-02-14 14:09:52

标签: webview javafx load

我有一个奇怪的问题:当我向webview插入新内容时,它会通过时间跟踪刷新模式失败。如果有人有 - 分享如何解决问题。

插入/刷新我使用:

private static WebEngine FormSee;
    private static JFXPanel fxContainer;
    private static WebView webPage;


    JScrollPane scrollPane_1 = new JScrollPane();
         scrollPane_1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
         scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
         scrollPane_1.setBounds(0, 33, 1297, 613);
         contentPane.add(scrollPane_1);


         fxContainer = new JFXPanel();
         scrollPane_1.setViewportView(fxContainer);
         fxContainer.setPreferredSize(new Dimension(332, 94));
         // create JavaFX scene 
         Platform.runLater(new Runnable() { 
         @Override 
         public void run() { 
         createScene(""); 
         } 
         });


 private static void createScene(String HtmlCont) { 
         StackPane root = new StackPane(); 
         Group group = new Group(); 
         Scene scene = new Scene(group); 
         WebView webView = new WebView(); 

         webView.setZoom(Double.valueOf(VARIABLE.GlobalSett.get("PreSeeZoom")));

         FormSee = webView.getEngine();

         FormSee.loadContent(HtmlCont);        



         root.getChildren().add(webView); 
         fxContainer.setScene(new Scene(root)); 
         }


 public static void loadURL(final String url) {


         Platform.runLater(new Runnable() { 
             @Override 
             public void run() {

                 FormSee.loadContent(url);


             } 
             });



        }

并致电loadURL ("<html> <head></head> <body> .... </body></html>");

谢谢。

0 个答案:

没有答案