This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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
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?.
 
wood burning stoves
 
subject: Animated gif not getting animated in JLabel
 
Similar Threads
running gifs
How do I display an image on a JLabel
RE: image ico
Adding a background image
Converting to an Animated GIF or something similar