Why can't I embed Ace Editor into WebView?
Asked Answered
C

1

0

I am attempting to make a simple editor in JavaFX 2.2. I downloaded Ace Editor repository and created a test page which works fine when double clicked.

However, it does not work when I try to embed it into the 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");
    }
}  

Can someone please tell me what is wrong?

Corotto answered 27/10, 2013 at 14:25 Comment(5)
Note: Google opens properlyCorotto
Try adding the FirebugLite and check out the console if there are errors.Natatory
@AndreyChaschev and how do I add the tag you showed to the webview ?Corotto
Add it under the <head> anywhere: <script src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'>Natatory
It would be better to start a chat. Starting it from previous questionCorotto
S
-1

It works for me when the absolute file path : try

File f = new File("/home/little/Downloads/AceEditor/ace-builds-master/MyTrial.html");
String StrURL = f.toURI().toURL().toString(); 
engine.load(StrURL);
Scheer answered 24/7, 2014 at 15:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.