Problems with images when compiled

前端 未结 2 731
暗喜
暗喜 2020-12-21 23:37

I have been all over the internet trying to work out how to get an image icon displayed after compiling into a runnable jar. I discovered this problem way too late, I ran my

2条回答
  •  星月不相逢
    2020-12-21 23:59

    As from your screenshot, the image exists in a folder called "images". Put it in a folder inside your classpath: src/images/success.jpg and call:

    ImageIcon a = new ImageIcon(getClass().getResource("/images/success.jpg")); 
    

提交回复
热议问题