Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GIF Image

 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai friends,
I have a problem with GIF File. The gif file i displayed is animated only once after the first move it stops. Can I make it run contineously
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that's embedded in the animated GIF when it is made. So, if you created the GIF yourself, then just recreate it with whatever property you have to set to make it 'loop', otherwise I don't think you'll be able to.
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
But that is not the problem. I have a gif which repeats animation when it completes on cycle. But when i added the picture to a label and displayed. it is just moving for one cycle then it stops.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried this with different animated GIFs? Is it a problem with all animated GIFs or only this one? That way you could know if it was a problem with the GIF or with the JLabel...

I tried using an animated GIF as an Icon on a JLabel and it worked... The GIF looped forever... I'm using JDK 1.4.2_01 on Windows 2000, in case that's important.
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
I tried with different files and the same problem for all those. Its not just because of my gif, I used the statement
lbl_pic = new JLabel(new ImageIcon("animate.gif"),JLabel.CENTER);
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which JDK version and OS are you using?

Also, try setting the component you are adding the animated GIF to as the ImageObserver of the icon... you'll need to do something like this :



Not sure if this will help your particular problem, but I found that this cleared up some problems people were having with animated GIFs in Java.
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai,
I tried with your code but still its in the same mood. It moves only for the one cycle. I tried with another image that i downloaded from a site. it also has the same problem. So i dont think its because of the picture.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post what version of the JDK you are using, and on what OS?

It might be a problem with whatever version you are using, since it worked for me in JDK 1.4.2 on Windows 2000.
 
Jithesh Kozhipurath
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Nathan,

I am using jdk1.4 and the windows 98. I tried it in win NT and JDK 1.3 but the same problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic