Get image from relative path

前端 未结 8 1900
囚心锁ツ
囚心锁ツ 2021-02-03 13:01

In my project I have 2 packages. images - contain images and notification - contain java files

In notification/main.java I get Image o

相关标签:
8条回答
  • 2021-02-03 13:31

    i've also been on this and it turns out that you need to create a package inside of your src folder. for instace if you create a package called images inside of the src folder, your relative path will be /images/yourimage.png.

    Notice that the slash(/) must be there! more info here http://forums.macrumors.com/showthread.php?t=533922

    it worked for me

    0 讨论(0)
  • 2021-02-03 13:32

    You could also try

    Image image = new ImageIcon(path).getImage();
    
    0 讨论(0)
提交回复
热议问题