Skip to main content

Practical-45

Create an Applet program that print Hello Applet.


Introdution

An applet is a small program designed to be embedded in a web page, similar to an image or an advertisement. It is written in a special programming language, usually Java. This program will create a simple "Hello Applet" program, which will print the text "Hello Applet" on a webpage.

Code

import java.awt.*;
import java.applet.*;

public class HelloApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Hello Applet", 25, 25);
}
}

Output

Hello Applet
Explanation

The code creates an applet which is a class which extends from the Applet class. A method 'paint' is defined which during runtime prints the text “Hello Applet”. The coordinates provided as 25 and 25 depict the location of the text.