The ImageIcon has a setImageObserver method that is utilized. You
would need to do something similar.
Quoting [EMAIL PROTECTED]:
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.
===========================================================================
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".