I want to ask about a problem in my project:
I have a class that extends JFrame
, and I want to change the Java icon on that frame to another icon using this code:
setIconImage(new ImageIcon(getClass().getResource("icon.PNG")).getImage());
I'm using NetBeans
, and when I run my project from NetBeans, it runs normally, but when I run it from the jar, it does not run.
Then, when I remove that code, my jar runs normally with the Java icon in the frame.
Can anyone can tell me what might be wrong with that code?