Java Applets - How to create a simple applet
Posted by JanWan
Last Updated: September 04, 2013

Java Applets

This lesson discusses the basics of Java applets, how to develop applets that interact richly with their environment.

A Java applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the java.applet.Applet class. The Applet class provides the standard interface between the applet and the browser environment.

Swing provides a special subclass of the Applet class called javax.swing.JApplet. The JApplet class should be used for all applets that use Swing components to construct their graphical user interfaces (GUIs).

The browser's Java Plug-in software manages the lifecycle of an applet.

Sample of Java Applet:

Applet Screen

Source code for the Applet


 * This program run the Applet and prints a few strings


import javax.swing.*;

import java.awt.*;


 * @author JWAN



public class Jay extends JApplet{

public void paint(Graphics n){


n.drawString("My first Java Applet:\n", 25, 15);

n.drawString("print:>", 25, 30);

n.drawString("Jan Wan", 25, 45);




Related Content
Car Loan Applet in Java
Car Loan Applet in Java
gideonna | Apr 13, 2016