Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Animated GIF - not working properly

807588Jan 26 2009 — edited Jan 27 2009
Hi,

I'm trying to get an animated GIF working in my swing program. I am drawing on a JPanel using paintComponent.

Here's the thing: It will animate, (faster then it should) and then pause animation for 5 seconds, then animate again. I am trying to achieve constant animation, at the framerate in which is set inside of the GIF file. Is there a better method to use then what I am using? It's not a repaint problem, as I am repainting constantly. Here's what I got:
String filename = "myimage.gif";
Image img = Toolkit.getDefaultToolkit().getImage(filename);
g.drawImage(img, x + 28, y + 79, this);
A code snippet would be helpful as I am only two weeks into Java and have difficultly reading the Sun documentation.

Thanks for reading,
Nate
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2009
Added on Jan 26 2009
14 comments
1,223 views