Playing media
Adding an image to a scene of the JavaFX application does not require the com.sun.* packages, so the --add-export VM options listed in the Embedding HTML section are not needed. But, it doesn’t hurt to have them anyway, so leave the --add-export options in place if you have added them already.
An image can be included in a scene using the javafx.scene.image.Image and javafx.scene.image.ImageView classes. To demonstrate how to do it, we are going to use the Packt logo, packt.png, located in the resources folder. Here is the code that does it (the start6() method of the HelloWorld class):
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
String file = classLoader.getResource("packt.png").getFile();
Text txt = new Text("What a beautiful image!");
FileInputStream input = new FileInputStream(file);
Image image = new Image(input...