public boolean waitForLoad(Image image){
  long start=System.currentTimeMillis();
  Thread.yield();
  int count=0;
  try {
    Toolkit toolkit=Toolkit.getDefaultToolkit();
    while (!toolkit.prepareImage(image,-1,-1,this)) {
      if (count > 1000) {
        log.severe(this + " - Timeout - " + (System.currentTimeMillis() - start)+ "ms - #"+ count);
        return false;
      }
      try {
        if (count < 10)         Thread.sleep(10);
 else         if (count < 100)         Thread.sleep(15);
 else         Thread.sleep(20);
      }
 catch (      InterruptedException ex) {
        log.log(Level.SEVERE,"",ex);
        break;
      }
      count++;
    }
  }
 catch (  Exception e) {
    log.log(Level.SEVERE,"",e);
    return false;
  }
  if (count > 0)   log.fine((System.currentTimeMillis() - start) + "ms - #" + count);
  return true;
}

public boolean waitForLoad ( Image image ) { long start = System . currentTimeMillis ( ) ; Thread . yield ( ) ; int count = 0 ; try { Toolkit toolkit = Toolkit . getDefaultToolkit ( ) ; while ( ! toolkit . prepareImage ( image , - 1 , - 1 , this ) ) { if ( count > 1000 ) { log . severe ( this + " - Timeout - " + ( System . currentTimeMillis ( ) - start ) + "ms - #" + count ) ; return false ; } try { if ( count < 10 ) Thread . sleep ( 10 ) ; else if ( count < 100 ) Thread . sleep ( 15 ) ; else Thread . sleep ( 20 ) ; } catch ( InterruptedException ex ) { log . log ( Level . SEVERE , "" , ex ) ; break ; } count ++ ; } } catch ( Exception e ) { log . log ( Level . SEVERE , "" , e ) ; return false ; } if ( count > 0 ) log . fine ( ( System . currentTimeMillis ( ) - start ) + "ms - #" + count ) ; return true ; }
wait until image is loaded .
