This is a Java Program to Load and Display an Image Using Applet
We have to write a program in Java such that it loads and displays an image using applet.
For loading and displaying image, we can have the following set of input and output.
When the Applet is Executed :
When the applet is executed, it is expected that the image is displayed in the frame.
1. Use method getImage to load the image.
2. Use method drawImage to draw the image.
Here is source code of the Java Program to load and display image using applet. The program is successfully compiled and tested using javac compiler on Fedora 30. The program output is also shown below.
/*Java Applet to Load and Display Image*/
public class Load_Image extends Applet
//Fucntion to Load the image
public void init()
//Function to draw the image
public void paint(Graphics g)
<applet code = Load_Image.class width=500 height=500>
To execute the applet use the following commands:
>>>javac Load_Image.java >>>appletviewer Load_Image.java
1. The method getImage(getCodeBase(),image file name) is used to get the image.
2. The method drawImage(image file,x,y,component) is used to draw the image starting from the x and y co-ordinates in the component specified.
Here’s the run time test cases to Load and Display Image using Applet.
Sanfoundry Global Education & Learning Series – Java Programs.