Java Applet Image Class Example
This example explain how you can display image in Java Applet. Basically first step to display image to your Java Apple is to upload Image to server as we will fetch it from the server only where generally our file resides. Second important point about the Image is that you should save image as PNG sothat there should not be any confusion like “My Image is not loading in Java Applet” as in JPG there are basically two extension jpg and jpeg so it may be happen that you save your image as jpg and you are writing jpeg that’s biggest common mistake of most of the new programmers. (even i also faced this so many times, but now i am careful for the same). finally use getImage() method to get image object and store it to some object and finally draw that Image on the Java applet using the graphics Object using drawImage().
<applet code="Applet7.class" height="300" width="300">
public class Applet7 extends Applet
public void init()
myimagereference = getImage(getDocumentBase(),"img1.png");
public void paint(Graphics g)
g.drawImage(myimagereference, 30,30, this);