How do you paint an Image onto a Graphics, assuming you are not a class that extends Component? My attempts to implement ImageObserver have so far all ended in failure :(. Any ideas appreciated…
I’m not 100% sure what you’re asking, but if I understand you correctly, you’re asking how to implement an ImageObserver? First and formost, you realize that ImageObserver is not necessary? You can just pass null instead. Secondly, have you looked at java.awt.MediaTracker?
To implement your own ImageObserver, you merely need to create a class that implements java.awt.image.ImageObserver, then test for attributes like ImageObserver.FRAME_BITS (one frame of an animation is loaded) and ImageObserver.ALL_BITS (the image is completely loaded).
Not sure if that’s what you’re looking for. You can always get a graphics object from a component with comp.getGraphics() (make sure it’s visible!) or from a BufferedImage with image.createGraphics().
Does that help?
Thanks; I was convinced a null for the ImageObserver agument would screw things up, and didn’t even try it, because I thought I’d tried that before (years ago, the last time I got into this situation :)).
Doh!
I did try to follow the API docs for the ImageObserver interface, but I found it really hard to know if what I was doing was working (Image’s weren’t displaying at all), and there were no errors or anything to go by :(.
Anyway, thanks for the help :).