Skip to Content
Java Network Programming, Second Edition
book

Java Network Programming, Second Edition

by Elliotte Rusty Harold
August 2000
Intermediate to advanced
760 pages
21h
English
O'Reilly Media, Inc.
Content preview from Java Network Programming, Second Edition

The ImageObserver Interface

It is sometimes said, only half in jest, that WWW stands for “World Wide Wait”, primarily because of the amount of time it takes for graphics-heavy pages to load. Although reading large files off a hard drive can be time-consuming, most users have trained themselves not to notice the time it takes; file loading seems to happen instantaneously. However, this is not the case when files are loaded from a network, particularly when that network is the Internet. It is not uncommon for even small images to take several minutes to load. Since Java loads images in a different thread than the main execution of a program, a program can do something while the pictures are downloaded. However, programs don’t get impatient; users do. It is a good idea to keeps users informed about how much of an image has been loaded and how much longer they can expect to wait. 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 discussing getImage( ), I said that the method returned immediately, before downloading the image. Downloading begins when you try to display the image or do something else that forces loading to start (for example, passing the Image object to the prepareImage( ) method of java.awt.Component). Because loading takes place in a separate thread, programs don’t have to spin their wheels while lots of pictures are downloaded; ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Network Programming, 4th Edition

Java Network Programming, 4th Edition

Elliotte Rusty Harold
Java Concurrency, 2/e

Java Concurrency, 2/e

Douglas Schmidt

Publisher Resources

ISBN: 1565928709Supplemental ContentCatalog PageErrata