• Advertisement
Sign in to follow this  

[java] getDocumentBase()

This topic is 3392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I keep getting Nul pointer exceptions when i try to load the base for an image. However i know that if i put this.getDocumentBase(); i shouldnt get a nul pointer but however when i g.drawImage (my_gif,0,0,this); i still get the error.

Share this post


Link to post
Share on other sites
Advertisement
I knew about getCodeBase(), however im using readytoprogram (yes im still learning) and i dont use jApplets. I still get an exception when i use getCodeBase().

Is there a file or something i have to import to use getCodeBase()?

thanks

Share this post


Link to post
Share on other sites
Srry, the error i get is still a null pointer.

Heres my code i dont know wut im doing wrong.

import java.awt.*;
import java.applet.*;

public class ImageExample extends Applet
{
Image my_gif;
URL Base;

public void init ()
{
Base = getCodeBase ();
my_gif = getImage (Base, "tier7.jpg");
}


public void paint (Graphics g)
{
g.drawImage (my_gif, 0, 0, 125, 150, this);
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement