Creating and Running the Applet
The folder view of the project is shown in the below image.
Step 1: First, create the file as AppletImage.java and enter the code into it.
Step 2: Once the code is been inserted then we need to create the AppletImage.html file, through which we will display the output.
HTML
<!DOCTYPE html> < html > < head > < title >Image Applet</ title > </ head > < body > < applet code = "AppletImage.class" width = "300" height = "300" > </ applet > </ body > </ html > |
Step 3: We need to have the image which we need to display in the applet. Here, we have used the gfglogo.png which is present in the code directory.
Step 4: Then we need to compile the Java code using the below command:
javac AppletImage.java
Step 5: Now finally we need to run the application using the below command:
appletviewer AppletImage.html
How to Display Image using Applet?
In this article, we will be using the Applet to display the image in proper layout. Here, we will display the image along with the text in the Applet Viewer.