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

Animated gif not getting animated in JLabel

 
Anand Natraj
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 = ImageIO.read(in);
} catch (IOException e) {
// TODO Auto-generated catch block

}

label.setText(message);
// label.setForeground(Color.RED);

icon=new ImageIcon(image);
label.setIcon(icon);


Am i missing something.. Please let me know.

Thanks in advance.

Thanks and Regards,
Anand
 
Sam Codean
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Craig Wood
Ranch Hand
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is discussed by Sun engineers in this thread: More work to do for animated GIF when using ImageIO?.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic