Here you can find the source of ensureImageLoaded(Component owner, Image image)
public static void ensureImageLoaded(Component owner, Image image)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; import java.awt.image.ImageObserver; public class Main { public static void ensureImageLoaded(Component owner, Image image) { if (image != null) { boolean done = false; Toolkit tk = owner.getToolkit(); if (tk != null) { int flags = tk.checkImage(image, -1, -1, owner); if ((flags & (ImageObserver.ABORT | ImageObserver.ALLBITS | ImageObserver.ERROR | ImageObserver.FRAMEBITS)) != 0) { done = true;//from w w w.j a va 2s . c om } } if (!done) { MediaTracker mt = new MediaTracker(owner); mt.addImage(image, 0); try { mt.waitForID(0); } catch (InterruptedException ex) { } } } } }