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 Animated gif not getting animated in JLabel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
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
Author

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 = 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

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: http://aspose.com/file-tools
 
subject: Animated gif not getting animated in JLabel
 
Similar Threads
running gifs
RE: image ico
How do I display an image on a JLabel
Adding a background image
Converting to an Animated GIF or something similar