When using the WebEngine object to load an svg file url located in a jar it does not display in a WebView node.
To reproduce:
When creating a NetBeans JavaFX applicaton project replace the hello world code inside the start() method with the following:
WebView browser = new WebView();
URL url = getClass().getResource("clock.svg"); // doesn't work
//URL url = getClass().getResource("clock.html"); // works
browser.getEngine().load(url.toExternalForm());
System.out.println("" + url.toExternalForm());
Scene scene = new Scene(browser,320,250, Color.rgb(0, 0, 0, .80));
primaryStage.setScene(scene);
primaryStage.show();
Assuming you have a valid SVG file the application tries to load from the following location:
jar:file:/C:/Users/cdea/jfx8ibe/DisplayingHtml5Content/dist/run562867542/DisplayingHtml5Content.jar!/jfx8ibe/clock.svg
Work around:
Now the funny thing is, if I have an identical file called 'clock.html' it works fine.
To reproduce:
When creating a NetBeans JavaFX applicaton project replace the hello world code inside the start() method with the following:
WebView browser = new WebView();
URL url = getClass().getResource("clock.svg"); // doesn't work
//URL url = getClass().getResource("clock.html"); // works
browser.getEngine().load(url.toExternalForm());
System.out.println("" + url.toExternalForm());
Scene scene = new Scene(browser,320,250, Color.rgb(0, 0, 0, .80));
primaryStage.setScene(scene);
primaryStage.show();
Assuming you have a valid SVG file the application tries to load from the following location:
jar:file:/C:/Users/cdea/jfx8ibe/DisplayingHtml5Content/dist/run562867542/DisplayingHtml5Content.jar!/jfx8ibe/clock.svg
Work around:
Now the funny thing is, if I have an identical file called 'clock.html' it works fine.