
How to add Image in Java Applet? what is getDocumentBase()?

/*<applet code="Image1" height=300 width=300>
</applet>
*/
import java.applet.*;
import java.awt.*;
public class Image1 extends Applet
{
Image img;
MediaTracker tr;
public void paint(Graphics g)
{
tr = new MediaTracker(this);
img = getImage (getCodeBase(),"logo.gif");
tr.addImage(img,0);
g.drawImage(img, 0, 0, this);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.