这让我起了墙。在java中,我试图在JOptionPane中获取一个图像,但它每次告诉我它无法找到图像时只给我一个例外。这是一个例外:
Exception in thread "main" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(Unknown Source)
at mad.madster.passbook.gui.GUILauncher.main(GUILauncher.java:67)
以下是代码:
ImageIcon icon = new ImageIcon(GUILauncher.class.getResource("/src/Bookimg.png"));
JOptionPane.showMessageDialog(null, "This is your first time "
+ "opening Passbook. You will "
+ "need to create a master password to login to "
+ "Passbook.", "test", JOptionPane.INFORMATION_MESSAGE, icon);
我尝试直接从我的电脑,甚至通过网站从我制作的res文件夹中抓取图像。没有任何作用,同样的例外。