How to load an image in Applet

Here’s an example to load an image in Applet, getImage() is use to load an image and display on screen.

package com.mkyong.applet;

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;

public class AppletExample1 extends Applet {

    Image img;
    public void init(){		
       img = getImage(getDocumentBase(), "");

    public void paint(Graphics g) { 		
       g.drawImage(img, 0, 0, this); 		

About the Author

author image
Founder of, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.