File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes GIF Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GIF Image" Watch "GIF Image" New topic
Author

GIF Image

Jithesh Kozhipurath
Ranch Hand

Joined: Aug 27, 2003
Posts: 76
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


Jithesh K
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

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.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Jithesh Kozhipurath
Ranch Hand

Joined: Aug 27, 2003
Posts: 76
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

Joined: Oct 18, 2000
Posts: 4121

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

Joined: Aug 27, 2003
Posts: 76
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

Joined: Oct 18, 2000
Posts: 4121

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

Joined: Aug 27, 2003
Posts: 76
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

Joined: Oct 18, 2000
Posts: 4121

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

Joined: Aug 27, 2003
Posts: 76
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GIF Image