Hi I am using NetBeans IDE and I have my images (what I am using in my project) in a folder named Images. When I am building jar it doesn't take that images. The code I am using to set image is,
buttonObj.setIcon(new ImageIcon("\Images\a.jpg")
any help please.
views:
121answers:
3
+1
A:
you can try with
URL loadingUrl = this.getClass().getResource("/images/a.jpg");
ImageIcon icon = new ImageIcon(loadingUrl);
using the getClass().getResource(..)
should be the correct approach to load files from a JAR. But remembers to check documentation for precise specification (if I'm not wrong it prepends the fully qualified package to the path you are loading from)
Jack
2010-04-24 10:10:06
@Arivu Thanks for the link. I got the answer.
Samurai
2010-04-24 10:50:45
A:
vkraemer
2010-05-07 15:04:45