How to Change Icon of Desktop Application?
829396Jun 1 2011 — edited Jun 2 2011Friends, i am developing one small software using Java Desktop Application in Netbeans. I want to change the icon of my application (cup of coffee). I have tried this code: URL url = new URL("myApplication/resourcesresources/camera.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url);
this.getFrame().setIconImage(img);
and
URL url = new URL("F:/Documents and Settings/Selva/My Documents/NetBeansProjects/HashCodeCracker/src/myApplication/resourcesresources/camera.png");
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(url);
this.getFrame().setIconImage(img);
i have searched in google and nothing works . Can anyone solve this problem?
Note:
This code works for me:
Toolkit kit = Toolkit.getDefaultToolkit();
Image frameIcon = kit.getImage("F:\\Documents and Settings\\Selva\\My Documents\\NetBeansProjects\\HashCodeCracker\\src\\hashcodecracker\\resources\\PasswordCrackerIcon.jpg");
this.getFrame().setIconImage(frameIcon);
But i am creating software. So i can not specify the location of the Image in one path. The user may run the software from anywhere. So the above code can not be used.
Thanks
Edited by: Blackstar on Jun 1, 2011 8:46 PM