Reputation: 15
hi every one i am trying to get to web application exist in my computer through java fx web view :
public void start(Stage stage) throws Exception {
WebView webView = new WebView();
WebEngine engine = webView.getEngine();
engine.load("172.0.0.0://HOWEB/documentation:8080");//loadContent("<html> href = C:/Users/kaisios/Desktop/attempt9000.html<\\html>");
VBox vBox = new VBox();
vBox.getChildren().addAll(webView);
Scene scene = new Scene(vBox, 800, 500);
stage.setScene(scene);
stage.show();
}
but it does not load the content . NOTE: I have already run xamp server but i think the formula of the url is wrong
Upvotes: 0
Views: 261
Reputation: 82461
There are several things wrong with the URL:
http
. You need to specify the IP in the protocol part of the url instead127.0.0.1
not 172.0.0.0
8080
)the correct url (assuming the rest is correct; use your standard webbrowser to check first) is
http://127.0.0.1:8080/HOWEB/documentation
You could also use a file URL, if you don't want to run a server:
File file = new File("C:/Users/kaisios/Desktop/attempt9000.html");
engine.load(file.toURI().toString());
Listening to the onError
event can help you identify the issue:
engine.setOnError(evt -> {
Throwable error = evt.getError();
if (error != null) {
error.printStackTrace();
}
});
Upvotes: 3