使用 NetBeans 将 ImageIcon 添加到按钮属性。
print.setFont(new java.awt.Font("Serif", 0, 14));
print.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project/print.gif")));
print.setMnemonic('P');
print.setText("Print");
print.setToolTipText("Print");
编译时显示
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
at project.Editor.initComponents(Editor.java:296)
我究竟做错了什么?