Displaying an image only when getImage() is done

How can I tell getImage() to return only when the picture's been completely loaded?

My application has a splash screen showing a background picture. Everything is fine, except for the fact that the Toolkit's getImage() method returns before having read the picture (62K inside the jar) in its entirety; this means the splash window comes up with its beans on a gray (or partly painted) background for a few seconds (ugly), until the picture finishes loading up. I'd like to avoid that. Anybody know how to fix that?

Eric

P.S. Here's the code I use to load the image:

URL u = ClassLoader.getSystemResource("images/Splash.jpg");

background = Toolkit.getDefaultToolkit().getImage(u);

[735 byte] By [Eric.Vautier] at [2007-9-26 1:22:35]
# 1

When loading images, you'd better use AWTs MediaTracker. Have a look in the documentation, the class is in the java.awt class.

if you're writing an applet you can put this in your init.

MediaTracker tracker = new MediaTracker(this);

tracker.addImage(background,0);

try{tracker.waitForAll();}catch(InterruptedException e){}

Phulip at 2007-6-29 0:59:53 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks, that did it ;-)
Eric.Vautier at 2007-6-29 0:59:53 > top of Java-index,Desktop,Core GUI APIs...