An ImageIcon is added to button properties using NetBeans.
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");
And when compiled it shows
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
at project.Editor.initComponents(Editor.java:296)
What am I doing wrong?
getClass().getResource("/project/print.gif"))
. I bet that the image that you're searching for cannot be found at the location that you're trying to point. – Schargel