Can't load javaFX Image

我只是一个虾纸丫 提交于 2021-02-11 15:11:08

问题


I'm having some troubles to load images in javaFX from the controller.

I put some images in the src/ folder and even in a folder img/ but still getting "Invalid URL or resource not found".

My directory is like

src/
    package/
      javaFXcontroller.java
      img/
         image.png

So I'm doing Image img = new Image("./img/image.png");

But I can't retrieve the image "java.lang.IllegalArgumentException: Invalid URL or resource not found"

Thanks for your help


回答1:


For those who may encounter the same problem, just drag your images into the src/ folder directly with eclipse and then require your image with the path new Image("image.png").



来源:https://stackoverflow.com/questions/53952266/cant-load-javafx-image

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!