Should I create a folder Images in netbeans

advertisements

I am developing a java application in netbeans, to save image icons, should i create a new images folder or there is already an images folder created?

I have created an image folder in the project, to set an image icon to JFrame,

URL iconURL = this.getClass().getResource("images/images.jpg");

    ImageIcon icon = new ImageIcon(iconURL);
    frame.setIconImage(icon.getImage());

error

Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:115)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:125)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:263)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:205)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:169)


Regardless of whether you have a directory created, I suspect this

getResource("images\\images.jpg");

is a problem and you should specify the resource path as images/images.jpg (i.e. a forward slash, regardless of the platform. The slash is a resource separator and not necessarily referring to the filesystem)

I wouldn't expect NetBeans to do anything for you without an explicit request, and as such you should create whatever folders/resources you need.