Embedding a Java applet.

Assuming that your GUI resides in a class named PanelXX, the process of embedding that GUI as an applet in a web page is quite simple.

Create an AppletXX.java file and compile this source code to create AppletXX.class.

public class AppletXX extends javax.swing.JApplet
   public void init()
      setContentPane(new PanelXX());

Make sure that AppletXX.class, PanelXX.class, and any other class files that are part of the GUI are in the same folder as AppletXX.html, or whatever you name the web page in which you are embedding the applet. The tag for applets is < applet > but you must also specify the code and size of the embedded applet. Setting the width and height values is like setting the size of a JFrame.For instance:

< applet code=AppletXX.class width=400 height=400 >

You can select View | Page Source from your browser to view the source code that produced this web page.

Click here to return to the main page.