samwaters
asked on
Loading images in Java Applet
Hi,
I would like to download images in a java applet, for displaying at any given time - i.e. getting the image from the server into an Image variable which can then be added to a Canvas or something similar.
I've experimented with getImage and MediaTracker, as in the code below, but am getting NullPointerException returned when it comes to adding the Image to the canvas.
In the code below, iCanvas is a class which adds the image object to an array and then draws all stored ones.
Any ideas (or a better way to do this)?
I would like to download images in a java applet, for displaying at any given time - i.e. getting the image from the server into an Image variable which can then be added to a Canvas or something similar.
I've experimented with getImage and MediaTracker, as in the code below, but am getting NullPointerException returned when it comes to adding the Image to the canvas.
In the code below, iCanvas is a class which adds the image object to an array and then draws all stored ones.
Any ideas (or a better way to do this)?
Image spl=getImage(getDocumentBase(),"LoadScreen.jpg");
MediaTracker mt=new MediaTracker(this);
mt.addImage(spl,1);
try
{
mt.waitForAll();
}
catch(Exception e)
{
}
iCanvas.addimagetodisplay(spl,0,0); //Null pointer exception at this line
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.