File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Animated gif not getting animated in JLabel

 
Anand Natraj
Ranch Hand
Posts: 53
  • 0
  • 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
  • 0
  • 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
Posts: 1535
  • 0
  • 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?.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic