How do I make sure an Image is loaded before I try to display it?
Created May 4, 2012
John Zukowski
You can use the AWT MediaTracker to start and wait for the loading of an Image object.
Image image = ...; MediaTracker tracker = new MediaTracker(component or this); tracker.addImage(image, 0); try { tracker.waitForAll(); } catch (InterruptedException e) { System.out.println("Interrupted while loading Image"); }
At this point, if everything went okay, the image would be loaded. You can check the status with statusAll() or statusID() to see if they loaded successfully.