I would like to apply icons to my program, but it gives me an error. It looks all good, that is why I dont have a clue what is wrong with it.
public static ImageIcon createIcon (String path) {
URL url = System.class.getResource(path);
if(url == null) {
System.err.println("Unable to load image: " + path);
}
ImageIcon icon = new ImageIcon(url); //here is line 30 in class Utils
return icon;
}
And his is the error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
at gui.Utils.createIcon(Utils.java:30)