Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

[HELP] setting a new icon for SingleFrameApplication  RSS feed

 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using NetBeans IDE 6.7.1 and I am creating my app.
Now, I wanted to change the default coffee icon of the SingleFrameApplication with my own...
I have these codes...



It comes with these error...

Uncaught error fetching image:
java.lang.NullPointerException
at sun.awt.image.URLImageSource.getConnection(URLImageSource.java:99)
at sun.awt.image.URLImageSource.getDecoder(URLImageSource.java:113)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.java:240)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)


MyIcon.bmp is located at the resources package within the main package of my program...

please help me with this one. i am quite convinced that my codes must be correct and i really have no idea what i am doing wrong..
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jhedzkie Skies wrote: (...)
MyIcon.bmp is located at the resources package within the main package of my program...

please help me with this one. i am quite convinced that my codes must be correct and i really have no idea what i am doing wrong..


have you tried this?

 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should be /resources/MyIcon.bmp, because the resources "package" (actually folder) is relative to the root. Without the leading / the system will look for the resources folder relative to the current class file.
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:It should be /resources/MyIcon.bmp, because the resources "package" (actually folder) is relative to the root. Without the leading / the system will look for the resources folder relative to the current class file.


thanks for your help guys. its running now but still doesnt change the icon of the frame...

this.getFrame(). probably is the one getting this wrong... i dont know really but, i did what you told me... and still it doesnt work..
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jhedzkie Skies wrote:
this.getFrame(). probably is the one getting this wrong... i dont know really but, i did what you told me... and still it doesnt work..


Did you run it in a debugger to see if it is null as you suspect? Even a simple System.out.println will help you confirm the same.
Why do you have to invoke getFrame(). A simple this.getClass() will also work.
Check the case of the image name on your file system, to confirm it is matching MyIcon.bmp. It has been noticed, especially on windows, that the OS sometimes changes it to MyIcon.BMP.
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for all your help. i figured it out and comparison shows that my compiler simply does not accept .bmp file extension as image icon... i tried it on .jpg, .gif and .png and your solutions worked. thanks guys.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!