Details
-
Bug
-
Status: Open
-
Trivial
-
Resolution: Unresolved
-
9.0, 10.0, 11.0
-
None
-
None
-
JDK 12, probably earlier versions too
Description
- Create new Maven project
- Add new JFrame form in the default created package
- Drop a JLabel anywhere in the form
- Right click the JLabel, click "Properties" and go to the three dots in the right of "Icon"
- Choose "Import to project" and select any image. Import the image to the same package
- Run the project and select the JFrame to be the Main class
- You will end-up with a NullPointer exception with the stack trace listed below:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
{{ at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)}}
{{ at com.mycompany.mavenproject1.NewJFrame.initComponents(NewJFrame.java:33)}}
...
That is the jLabel1.setIcon(new javax.swing.ImageIcon(...) call.
Checking the file structure - the image is correctly placed and existing in the SRC folder inside the related package subdirectory. The image is also visualized correctly in the Netbeans editor itself. It is also not related to the file name (bug is available with simple filenames too).
The issue is that Netbeans does NOT copy the image file into the "target" directory. If I copy the file manually, it works fine.
This happens only on Maven project.