2013-10-27 63 views
0

我試圖在JavaFX 2.2中做一個簡單的編輯器。我下載了Ace Editor存儲庫,並創建了一個測試頁面,雙擊時工作正常。爲什麼我不能將Ace Editor嵌入到WebView中?

但是,當我嘗試將其嵌入到WebView中時,它不起作用。

SSCCE

package web; 

import javafx.application.Application; 
import javafx.geometry.Pos; 
import javafx.scene.Scene; 
import javafx.scene.SceneBuilder; 
import javafx.scene.layout.StackPane; 
import javafx.scene.layout.StackPaneBuilder; 
import javafx.scene.web.WebEngine; 
import javafx.scene.web.WebView; 
import javafx.scene.web.WebViewBuilder; 
import javafx.stage.Stage; 

public class EditorTrial extends Application{ 
    WebView webView; 
    WebEngine engine; 
    StackPane stack; 
    Scene scene; 


    @Override 
    public void start(Stage primStage) throws Exception { 
     stack = StackPaneBuilder 
       .create() 
       .alignment(Pos.CENTER) 
       .build(); 

     webView = WebViewBuilder 
       .create() 
       .build(); 

     engine = webView.getEngine(); 
     engine.setJavaScriptEnabled(true); 
     engine.load("/home/little/Downloads/AceEditor/ace-builds-master/MyTrial.html"); 
     stack.getChildren().add(webView); 

     scene = SceneBuilder 
       .create() 
       .root(stack) 
       .build(); 

     primStage.setScene(scene); 
     primStage.sizeToScene(); 
     primStage.show(); 

    } 

    public static void main(String[] args) { 
     Application.launch("web.EditorTrial"); 
    } 
} 

有人能告訴我什麼是錯的?

+0

*注:谷歌正常打開* –

+1

嘗試添加'FirebugLite',並檢查了控制檯是否有錯誤。 –

+0

@AndreyChaschev,我如何添加你展示給webview的標籤? –

回答

-1

這對我的作品的時候絕對文件路徑: 嘗試

File f = new File("/home/little/Downloads/AceEditor/ace-builds-master/MyTrial.html"); 
String StrURL = f.toURI().toURL().toString(); 
engine.load(StrURL); 
相關問題