[4050] in java-interest

home help back first fref pref prev next nref lref last post

Re: Painting Images

daemon@ATHENA.MIT.EDU (Jim Graham)
Fri Dec 8 12:16:07 1995

Date: Fri, 8 Dec 1995 07:32:54 -0800
From: flar@bendenweyr.Eng.Sun.COM (Jim Graham)
To: Cristinij@segaoa.com
Cc: java-interest@java.Eng.Sun.COM


Jamie Cristini asks:
> > Howdie java folks,
> > I have an easy question, which is driving me crazy!  How does one load   
> > images in completely
> > before the applet starts?  My applets seem to display the images while   
> > their loading.  Is it possible to hold off on starting the applet until   
> > these images are loaded?

Use the java.awt.MediaTracker class.  The documentation for it is online:

	http://java.sun.com/JDK-beta/api/packages.html
	http://java.sun.com/JDK-beta/converting/images.html

> Try checking the width of the image you want to wait for.
> It will be -1 until it's loaded. Put it in a while-loop
> with a sleep() inside or someting like that.

The getWidth() method will return -1 until the width of the image is
known.  This has very little bearing on when the image will be completely
loaded since the width is one of the first things at the beginning of
most image file formats.  Also, it's bad practice to poll waiting for
information, especially when there are much better methods to use (i.e.
the MediaTracker).

				...jim
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post