If I supply an Icon to a JLabel constructor, and that Icon happens to represent 
an animated GIF, then the JLabel automatically handles animating the frames of 
the aGIF. So somehow, the Icon class is giving it enough information to be able 
to support the animation.

Now, say I have a reference to an Icon, and that's it. Not an ImageIcon, just a 
javax.swing.Icon. How do I get notified to draw the other frames of the 
animation? Right now, I am creating a BufferedImage, and having the Icon paint 
itself (via paintIcon) into the Graphics of that BufferedImage. I am passing in 
an ImageObserver to the paintIcon method (actually it's a Component that has 
overriden imageUpdate, but that never gets called.

The relevant code:

Image iconImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), 
BufferedImage.TYPE_3BYTE_BGR);

g = (Graphics2D) ((BufferedImage) iconImage).getGraphics();
g.setComposite(AlphaComposite.Src);
icon.paintIcon(observer, g, 0, 0); //observer overrides imageUpate


I want to get notified when I should render the next frame of the animation; I 
will respond by painting the Icon into a BufferedImage.

But I'm not sure how to do this.

Thanks,

Rob Ross
[Message sent by forum member 'robross' (robross)]

http://forums.java.net/jive/thread.jspa?messageID=166132

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to