我创建了一个14class的java项目。到目前为止,我一直在使用default-package。 今天我用我的所有类移动了:Refactor - Move,我创建了一个新的包。
这样做之后,我无法访问我的资源。运行我的MainForm类我收到此错误:
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at com.anreas.mls.MainForm.<init>(MainForm.java:279)
at com.anreas.mls.MainForm$1.run(MainForm.java:48)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
编辑:MainForm第279行:
btnHelp.setIcon(new ImageIcon(MainForm.class.getResource("images/help.png")));
文件夹结构:
如果有人知道我的意思,我会非常感激!
提前谢谢你:)