我想提出一個遊戲,我把一些圖片上的我的IDE /圖片文件夾,但計劃爲空指針異常error.my代碼加載ImageIcon的是這樣的加載一個ImageIcon從源
ImageIcon ac=new ImageIcon(getClass().getResource("images/actor.jpg"));
ImageIcon ac1=new ImageIcon(getClass().getResource("images/actor_shoot.jpg"));
//some codes
Image n=ac.getImage();
//some codes
我試着但無法找到,你的建議是什麼?謝謝。
操作系統,操作系統,IDE? – 2012-01-01 14:44:19
os:Win7,ide:NetBeans 6.9.1 – 2012-01-01 14:45:58
[Eclipse中的Java:我在哪裏將文件放在要使用getResource加載的文件系統上? (例如ImageIcon的圖像)](http://stackoverflow.com/questions/270197/java-in-eclipse-where-do-i-put-files-on-the-filesystem-that-i-want-to -load-usin) – Barett 2015-06-24 17:04:51