robertfleder
Programmer
I have about 25 icons to load. From some servers, I do not get a successful load. The results are random. I tried to use this status to reinstiated the image and the icon, but once a bad status it never changes. (Java 1.4, IE 6.0 IIS server). BTW, results vary based on server load.
Here's the code:
private ImageIcon getIcon(String f) {
Image im;
ImageIcon ii = null;
int retries = 3;
try {
while( retries > 0 ) {
im = getImage(f);
ii = new ImageIcon(im);
System.out.println("Loading: "+f+ " Status: "+
ii.getImageLoadStatus());
while(ii.getImageLoadStatus()==MediaTracker.LOADING )
try {
Thread.sleep(500);
} catch (Exception e) {}
if(ii.getImageLoadStatus() == MediaTracker.COMPLETE)
retries=0;
if( retries > 0 )
System.out.println("Load status "+
ii.getImageLoadStatus()+ " for: "+f);
retries--;
}
} catch( Exception e) {
System.out.println("Bad Filename: "+f);
System.out.println("Error: "+e);
}
return ii;
}