[2660] in java-interest
Re: Beta API and synchronous image loading
daemon@ATHENA.MIT.EDU (Jim Graham)
Mon Oct 9 20:44:47 1995
Date: Mon, 9 Oct 1995 14:41:49 -0700
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: java-interest@java.Eng.Sun.COM, sweh@mpn.com
> Does anyone have an idea on how to force preload of the images so that I
> can ensure the data is present (and so that .width() and .height() values
> are guaranteed to work!)
First, I would like to point everyone to the prebeta1 image porting guide:
http://www.javasoft.com/JDK-prebeta1/converting/images.html
To answer your specific question, you can use a class which implements
the ImageObserver interface to track the state of images as they load.
Unfortunately, you have to render the image at least once so that the
system knows which images and at what sizes you want the images scaled
before they will be downloaded. You also may have to deal with tracking
multiple images which can get cumbersome.
To help deal with this, I have written a utility class called the
MediaTracker. I have a pointer to it and its documentation off of
my home page:
http://www.javasoft.com/people/flar/
Feel free to download it and use it with your applets. We are working
on adding it officially to the Java APIs, but in the meantime the above
version can be compiled with your applet and will work with the existing
JDK and netscape 2.0 beta.
...jim
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com