Java Swing ImageIcon, where to put images?

后端 未结 3 1653
小蘑菇
小蘑菇 2020-12-03 22:37

I\'m following this tutorial for java swing games: http://zetcode.com/tutorials/javagamestutorial/movingsprites/

At this point:

ImageIcon ii = new Im         


        
3条回答
  •  独厮守ぢ
    2020-12-03 22:51

    new ImageIcon(this.getClass().getResource());
    

    This means that the image is present in the directory where the underlying class file is existing. So, you should save your image in the same directory where the class file of current java file will reside.

提交回复
热议问题