2016-04-06 11 views
0

Netbeans 7.2(Java 1.7.u79)とNetbeans 8.0.2(Java 1.8 u45)で次のコードを実行しようとしましたが、動作しません。JavaFX 2.0と8.0でWebViewを読み込む

package com.main; 

import javafx.application.Application; 
import javafx.event.ActionEvent; 
import javafx.event.EventHandler; 
import javafx.geometry.Pos; 
import javafx.scene.Scene; 
import javafx.scene.control.Button; 
import javafx.scene.layout.VBox; 
import javafx.scene.web.WebEngine; 
import javafx.scene.web.WebView; 
import javafx.stage.Stage; 

    public class RBrowser extends Application { 

     @Override 
     public void start(Stage primaryStage) { 
      WebView browser = new WebView(); 
      final WebEngine webEngine = browser.getEngine(); 
      webEngine.load("http://docs.oracle.com/javafx/2/webview/jfxpub-webview.htm"); 

      Button b = new Button("Show Console"); 
      b.setOnAction(new EventHandler<ActionEvent>(){ 
       @Override 
       public void handle(ActionEvent t) { 
        webEngine.executeScript("if (!document.getElementById('FirebugLite')){E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;E = E ? document['createElement' + 'NS'](E, 'script') : document['createElement']('script');E['setAttribute']('id', 'FirebugLite');E['setAttribute']('src', 'https://getfirebug.com/' + 'firebug-lite.js' + '#startOpened');E['setAttribute']('FirebugLite', '4');(document['getElementsByTagName']('head')[0] || document['getElementsByTagName']('body')[0]).appendChild(E);E = new Image;E['setAttribute']('src', 'https://getfirebug.com/' + '#startOpened');}"); 
       } 
      }); 

      VBox root = new VBox(); 
      root.setAlignment(Pos.CENTER); 
      root.getChildren().addAll(browser,b); 

      Scene scene = new Scene(root, 700, 550); 

      primaryStage.setTitle("Google Map"); 
      primaryStage.setScene(scene); 
      primaryStage.show(); 
     } 

     /** 
     * @param args the command line arguments 
     */ 
     public static void main(String[] args) { 
      launch(args); 
     } 

    } 

私は私のコードで何が悪い、Google Chromeブラウザでhttp://docs.oracle.com/javafx/2/webview/jfxpub-webview.htmにアクセスしようと、それが正常にロードされたのですか?

+0

回答の詳細を教えてもらえますか? エラーがありますか、または出力がわかりますか? – jr593

+0

BTW NetBeans 8.1の私には役に立ちます – jr593

+0

ここのコードも完全に機能します。 Mac OSX Capitan上でJava 1.8.0_74を使用してEclipse Mars2で実行するどのコンソールエラー/出力? – JDDelgado

答えて

0

インストールしたJDKのバージョン。私はWindows 8.1でIDK 8u77を使用していて、Eclipse Mars2でコードを実行していますが、完全に機能しました。試してくださいlatest version from here.それが動作するかどうかを確認してください。

関連する問題