Waiting for an image to load

The java.awt.image.ImageObserver interface allows you to monitor the loading process so that you can keep the user informed, and use the image as quickly as possible once it does load.

When an ImageProducer receives additional data from an image, it calls the imageUpdate() method in each registered client. The default imageUpdate() method in java.awt.Component repaints the component when the image has changed.

However, variables that are set using a method like getWidth() or getHeight() are not updated automatically when imageUpdate() is called. It's your job to update them when the image changes.

Exactly how much data an ImageProducer receives before it calls imageUpdate() is unpredictable. Some texts (Graphic Java and my own Java Network Programming to mention two) incorrectly state that imageUpdate() is called for each scanline. This is not necessarily true.


Previous | Next | Top
Last Modified March 31, 1997
Copyright 1997 Elliotte Rusty Harold
elharo@metalab.unc.edu