'JavaFX SceneBuilder ImageView not working
I need to create a GUI with SceneBuilder. I added an ImageView to my interface and set the path to my image correctly. The image is showing inside SceneBuilder, but when I run my application, the image is not there.
I put the image inside "img/placeholder.png", and then directly into my root directory. Doesn't matter where I put it, it isn't working.
The path to my gui.fxml file:
/src/gui/gui.fxml
The path to my image file:
/placeholder.png
Can anybody help me please?
Solution 1:[1]
There's an easier solution to your problem, without the need of adding or removing any code.
Once you had created an ImageView control in Scene Builder and chosen an image from your computer, select the "gear" icon right beside the ellipses button and select "switch to absolute path".
Image will then automatically appear when you run the code.
Solution 2:[2]
Another solution in some particular context (maven related)
Given /src/main/resources/foo/gui.fxml and /src/main/resources/foo/img/foo.png, if you create an image view in SceneBuilder and set the image to foo.png, the url reads @img/foo.png. Unfortunately the image does not show in the application. If you change the image url to @/foo/img/foo.png then the image won't show anymore in SceneBuilder but it will show in the application.
SceneBuilder 8.2.0, JDK 1.8, IntellJ IDEA 2016.1
Solution 3:[3]
There should be @ as following in image URL. Put image file in inside project folder either same package or different package.
<Image url="@../image/profile_pic.png" />
Solution 4:[4]
Just try to refresh Eclipse's System Explorer. I solved it this way.
Solution 5:[5]
Path From Content Root src/main/resources/assets/POMME.png =
<Image url="@../../../assets/POMME.png" />
Solution 6:[6]
This is because you haven't added jfoenix jar in your program. Add jfoenix jar to your project [xdezo.com][1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Max |
| Solution 2 | Sнаđошƒаӽ |
| Solution 3 | Jayawickrama |
| Solution 4 | jojo |
| Solution 5 | Bouteina |
| Solution 6 |
