Applets
Introduction
The JApplet class
The Applet class is an AWT class and is not designed to work with Swing components. To use Swing components in Java applets, it is necessary to create a Java applet that extends javax.swing.JApplet, which is a subclass of java.applet.Applet. JApplet inherits all the methods from the Applet class. In addition, it provides support for laying out Swing components.
// WelcomeApplet.java: Applet for displaying a message import javax.swing.*; public class WelcomeApplet extends JApplet { /** Construct the applet */ public WelcomeApplet() { add(new JLabel("Welcome to Java", JLabel.CENTER)); } }
<html> <head> <title>Welcome Java Applet</title> </head> <body> <applet code = "WelcomeApplet.class" width = 200 height = 70> </applet> </body> </html>