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)?
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

Open in new window

samwatersAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sciuriwareCommented:
If you load images as ImageIcon monitoring is automatic:

     new ImageIcon(String pathname);

or

    new ImageIcon(URL path);

;JOOP!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
objectsCommented:
> iCanvas.addimagetodisplay(spl,0,0); //Null pointer exception at this line

check iCanvas has been initialized
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.