This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Animated gif not getting animated in JLabel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Animated gif not getting animated in JLabel" Watch "Animated gif not getting animated in JLabel" New topic

Animated gif not getting animated in JLabel

Anand Natraj
Ranch Hand

Joined: May 17, 2004
Posts: 53
Hi All,

I am new to swing. I am adding a gif to a JLabel. My gif is getting displayed properly in the JLablel but my image is not getting animated. Please find below the code :

JLable label= New JLabel();

InputStream in = this.getClass().getResourceAsStream("/resources/backup.gif");

try {
image =;
} catch (IOException e) {
// TODO Auto-generated catch block


// label.setForeground(Color.RED);

icon=new ImageIcon(image);

Am i missing something.. Please let me know.

Thanks in advance.

Thanks and Regards,
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
as far as i know swing does not support gifs. so you may have to rethink about using animation using gifs
try writing your own animator classes

-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
This is discussed by Sun engineers in this thread: More work to do for animated GIF when using ImageIO?.
I agree. Here's the link:
subject: Animated gif not getting animated in JLabel
jQuery in Action, 3rd edition