[jboss-user] [Beginners Corner] - NetBeans IDE: Classpath not working for a JLabel icon image
victorj42
do-not-reply at jboss.com
Sat Oct 27 10:56:40 EDT 2007
Hi all,
I get an error after using NetBeans to select an image file for a JLabel icon.
IDE code that works:
gallows.setIcon(new javax.swing.ImageIcon("K:\\Hangman\\images\\gallows.gif"));
IDE code that fails when I run the project:
gallows.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gallows.gif")));
How I'm selecting the image location:
1) from the IDE click the [...] next to the icon property of my label then choose classpath and click [select file].
2) I am able to navigate to the file correctly and it is displayed in the preview window. I can even see it when I click on the test form button.
If I run my file I get an error:
netbeans Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.(ImageIcon.java:138)
at Keyboard.initComponents(Keyboard.java:175)
at Keyboard.(Keyboard.java:15)
<following errors removed by me>
I hope someone can help me
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4099593#4099593
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4099593
More information about the jboss-user
mailing list