• Post Reply Bookmark Topic Watch Topic
  • New Topic

gif images

 
dubey vandana
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have made my own gif image and want to put it at the top left corner where generally we get cup image of java.
i used following method but it does not work.
setIconImage(Toolkit.getDefaultToolkit().getImage("neural.gif"));
pl reply asap
thanx
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure "neural.gif" is in the same directory as your program, and that it is spelled exactly the same... If that doesn't work put in the full path to the image, i.e. "C:\java_program\images\neural.gif".

-Nate
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dubey,
That should work for a Frame or JFrame. If your image is large you might want to add a MediaTracker to make sure you have the image before you set it to the frame.
NOTE: If you are trying to make it work for JDialog you must change the parent icon because it just inherits it.
Regards,
Manfred.
 
remi vandana
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
sir, i have put this image in same directory and also given full path.
the size of image is not so big tht it wont be accomodated.
If have been suggested to use Meidia tracker(mt). Can u plz give some examples of this mt.
 
remi vandana
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
No, tht gif img is not working for JFrame.
sir, i have put this image in same directory and also given full path. The size of image is not so big tht it wont be accomodated.
Can u plz give some examples of Meidia tracker which solves this problem.
thanx
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The MediaTracker class loads the actual image data into your Image object before it is referenced the first time. This isn't usually a problem with small, local images, but it can be really important to do in applets or with large images. The easiest way to use MediaTracker is:



-Nate
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!