JApplet

This tutorial is now obsolete. Please see updated materials in the coreservlets.com Java programming tutorials.


1. No browser yet supports Java 1.2.

2. Most usage is the same as with Applet

3. Main differences in use

4. JApplet Example: Source Code

This simple example shows the steps required to get what you would have in the AWT if you had a simple applet whose init method did nothing but drop three buttons into the window.

JAppletExample.java (Download source code)

import java.awt.*;
import javax.swing.*;

public class JAppletExample extends JApplet {
  public void init() {
    WindowUtilities.setNativeLookAndFeel();
    Container content = getContentPane();
    content.setBackground(Color.white);
    content.setLayout(new FlowLayout()); 
    content.add(new JButton("Button 1"));
    content.add(new JButton("Button 2"));
    content.add(new JButton("Button 3"));
  }
}
Note: the setNativeLookAndFeel code is presented in WindowUtilities.java.

4. JApplet Example: Result

JAppletExample Output


This page is part of my Quick Swing Tutorial for AWT Programmers. © 1999 Marty Hall. All source code freely available for unrestricted use. Created for for work in the Research and Technology Development Center of the Johns Hopkins University Applied Physics Lab, for courses in the Johns Hopkins Part-Time MS Program in Computer Science, and for various industry seminars and Java short courses.