Solved

Re-loading corrupt images

Posted on 1997-06-26
3
257 Views
Last Modified: 2006-11-17
I am using MediaTracker to keep track of the loading status of some images that I need for my applet. Even though all images are completely and correctly in the browsers cache (check with about:cache), MediaTracker.isErrorAny() and getErrorsAny() will return true (I am using a separate MediaTracker for each image, so I think using the Any-functions is not the problem :).

The Image objects that I try to load the pictures in will be (null).

The really strange things is that when you start the applet again (without flushing the cache), the pictures MAY load.

Whats going wrong here?

Netscape 3/4 and MSIE behave the same way on Win95/NT.
0
Comment
Question by:intouch_chris
3 Comments
 
LVL 1

Expert Comment

by:mann061997
Comment Utility
Did you call one of the waitFor...() methods before
accessing the images?

0
 

Author Comment

by:intouch_chris
Comment Utility
Yes, I made a call to waitForAll() and it returns without any Exceptions...
0
 
LVL 3

Accepted Solution

by:
garik earned 200 total points
Comment Utility
I can't reproduce this error now, but I remember having exactly the same problem. That's why I'm using while() loop in my applets:

while ((m_Tracker.statusID(id, true) & m_Tracker.COMPLETE) == 0)
{
  try {
    m_Tracker.waitForID(id);
  } catch (InterruptedException e) {}
}

There was a time when I had this problem persistently: MediaTracker would indicate an error on a first run, but the second (or third?) would complete normally. I gave up on figuring out the reason and using this loop since then. You might want to add cycle counter to get out of the loop when there is a real error, but give it 3-4 spins - I'm pretty sure your problem will go away.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now