My program is supposed to upload a image from a file and then it displays that image as the background. My problem is that when I create an Image
object in it\'
The problem is that the constructor of Image
is expecting a String url
, whereas you're passing it a File
. Any good IDE will tell you what a given method is expecting as its parameters; find that keyboard shortcut and use it (Ctrl + P in IntelliJ). From there, all you have to do is find a way to convert a File
to a String
representing its url. In this case:
Image image1 = new Image(file.toURI().toString());
Note that you are never actually setting your background image, you need to add the following line to your lambda:
stac.setBackground(new Background(backgroundImage));
For this though, you will have to move the declaration of stac
above your action listener.