I have an instantiated File
object. I know it contains a picture format. I don't know where on the system the file is placed, other than the methods of File
available to me getPath(), getAbsolutePath()
etc.
My question is: how can I instantiate a JavaFX Image
object with the picture in my File
?
File
provides a method to retrieve the URL for the file and the Image
constructor expects a URL String
.
Image imageForFile = new Image(file.toURI().toURL().toExternalForm());
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments