Sign in to follow this  
DutchValiance

[java] getDocumentBase()

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this