From forum:
http://forums.java.net/jive/thread.jspa?threadID=47066&tstart=15
The API documentation for Applet.getImage says:
This method always returns immediately, whether or not the image exists.
When this applet attempts to draw the image on the screen, the data will be loaded.
The graphics primitives that draw the image will incrementally paint on the screen.
This is not true with Java Plug-in 1.6.0_10-rc2, as shown in the applet below.
It has been tested with Java Plug-in 1.6.0_01 and Java Plug-in 1.6.0_10-rc2.
The applet has been compiled with jdk1.6.0_03 and run in IE 6.0.2900.5512 SP3
on Windows XP SP3.
The tests were made using a dial-up connection, the ouput shows 9 sec for
getImage to return. Even on a slow connection, it should return immediately.
Really inconvenient!
import java.applet.*;
import java.awt.*;
import java.awt.image.*;
public class GetImageBug extends Applet implements ImageObserver
{
String image1Name = "image1.jpg";
String image2Name = "image2.jpg";
String image3Name = "image3.jpg";
String image4Name = "image4.jpg";
public void init()
{
new GetImageThread(this, image1Name).start();
new GetImageThread(this, image2Name).start();
new GetImageThread(this, image3Name).start();
new GetImageThread(this, image4Name).start();
}
public boolean imageUpdate(Image img, int infoflags,
int x, int y, int width, int height)
{
if ( (infoflags & ImageObserver.ALLBITS) != 0 )
return false;
return true;
}
}
class GetImageThread extends Thread
{
Applet applet;
String imageFileName;
GetImageThread(Applet applet, String imageFileName)
{
this.applet = applet;
this.imageFileName = imageFileName;
}
public void run()
{
long time0 = System.currentTimeMillis();
Image image = applet.getImage(applet.getCodeBase(), imageFileName);
System.out.println("getImgage(" + imageFileName + ") took " +
(System.currentTimeMillis()-time0) + " millis.");
applet.prepareImage(image, applet);
}
}