Question

How do I change the default application icon in Java?

I tried the above code using Netbeans 7.0 but I'm not sure where the resources directory needs to be? If I use the one Netbeans has under files listing. It keeps giving me this error. Also, is the code correct?

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)

using this code:

URL url;
url = ClassLoader.getSystemResource("/com/pbuddie/resources/Server.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url);
clientUI.setIconImage(img);

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top