Basic HTML version of Foils prepared 13 October 97

Foil 20 Image Downloading -- imageObserver, MediaTracker

From Java Tutorial, July 1, 1996 CSC499(JSU) CPS406/606 -- Fall Semester 97. by Nancy J. McCracken,Geoffrey C. Fox

Look in the init method to see the use of prepareImage to determine when image downloading is finished.
When drawImage is called, it draws only the pixels of the image that are already available.
Then it creates a thread for the imageObserver. Whenever more of the image becomes available, it activates the method imageUpdate, which in turn call paint and drawImage, so that more of the image will show on the screen.
The default imageUpdate doesn't work if you are double buffering the window in which the image appears.
More control over showing the image as it downloads can be obtained by working with the MediaTracker class, using methods that tell you when the image has fully arrived.
  • Another method is prepareImage(MyImage, this);
  • which returns a boolean that is true when image is fully downloaded.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998