Java Utililty Methods Image Wait

List of utility methods to do Image Wait

Description

The list of methods to do Image Wait are organized into topic(s).

Method

ImagewaitFor(Image image)
Wait until the image has been loaded completely
try {
    MediaTracker tracker = new MediaTracker(DUMMY_COMP);
    tracker.addImage(image, 0);
    tracker.waitForAll();
} catch (InterruptedException e) {
return image;
voidwaitForImage(Image image)
wait For Image
new ImageIcon(image).getImage();
booleanwaitForImage(Image image)
wait For Image
int id;
synchronized (component) {
    id = sid++;
tracker.addImage(image, id);
try {
    tracker.waitForID(id);
} catch (InterruptedException e) {
...
booleanwaitForImage(Image image)
Waits for an image to load fully.
int id;
synchronized (sComponent) {
    id = sID++;
sTracker.addImage(image, id);
try {
    sTracker.waitForID(id);
} catch (InterruptedException ie) {
...
booleanwaitForImage(Image image, Component c)
Returns true if the given image is loaded successfully.
MediaTracker tracker = new MediaTracker(c);
tracker.addImage(image, 0);
try {
    tracker.waitForAll();
} catch (InterruptedException ie) {
return (!tracker.isErrorAny());
booleanwaitForImage(Image image, Component component)
wait For Image
try {
    MediaTracker mediaTracker = new MediaTracker(component);
    int i = new Random().nextInt();
    mediaTracker.addImage(image, i);
    mediaTracker.waitForID(i);
    return true;
} catch (InterruptedException e) {
    return false;
...
booleanwaitForImage(Image image, Component component)
Wait for an image to be ready
MediaTracker mediaTracker = new MediaTracker(component);
mediaTracker.addImage(image, 0);
try {
    mediaTracker.waitForID(0);
} catch (InterruptedException e) {
    return false;
return true;
...
voidwaitForImage(java.awt.Image image)
Waits until image is fully loaded, so ready for drawing.
BufferedImage bufferedImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bufferedImage.createGraphics();
final Object done = new Object();
ImageObserver imageObserver = new ImageObserver() {
    public boolean imageUpdate(java.awt.Image img, int flags, int x, int y, int width, int height) {
        if (flags < ALLBITS) {
            return true;
        } else {
...
voidwaitForImage(java.awt.Image image)
wait For Image
s_mediaTracker.addImage(image, 0);
try {
    s_mediaTracker.waitForID(0);
} finally {
    s_mediaTracker.removeImage(image);
voidwaitForImageData(Image image, Component comp)
Waits until all the data of an Image is present.
if (comp == null) {
    comp = HELPER_LABEL;
MediaTracker tracker = new MediaTracker(comp);
tracker.addImage(image, 0);
try {
    tracker.waitForID(0);
} catch (Exception ex) {
...