Java examples for 2D Graphics:Image
wait For Image
//package com.java2s; import java.awt.*; import java.awt.image.*; public class Main { protected static Canvas waitComponent; public static void waitForImage(Image image) { if (waitComponent == null) { waitComponent = new Canvas(); }//from w w w .ja v a 2 s . co m waitForImage(waitComponent, image); } public static void waitForImage(Component comp, Image img) { MediaTracker mt = new MediaTracker(comp); mt.addImage(img, 0); try { mt.waitForAll(); } catch (InterruptedException e) { } } public static void waitForImage(Component comp, Image img, ImageObserver imo) { final MediaTracker mt = new MediaTracker(comp); final Image image = img; final ImageObserver imageobserver = imo; final Component fcomp = comp; new Thread(new Runnable() { public void run() { mt.addImage(image, 0); try { mt.waitForAll(); } catch (InterruptedException e) { } imageobserver.imageUpdate(image, 0, 0, 0, image.getWidth(null), image.getHeight(null)); } }).start(); return; } }