So, I am creating a GUI interface for the project via Netbeans (using it is a requirement). Everything is fine until I add an Icon for a label. The generated code is below:
jLabel25 = new javax.swing.JLabel();
jLabel25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/mycompany/sostarnyba/images/map.png")));
jLabel25.setText("");
I add the icon exactly as the person in this question shows it: Netbeans ImageIcon not displaying Except my app does not run at all.
When the icon is removed, everything runs, but when it is added it does not. The error is: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "java.net.URL.toExternalForm()" because "location" is null.
What am I doing wrong?