Figure 4: A GUI/applet skeleton created by function generateAppletGUI

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

public class j12swingappguimenu extends JApplet {

 public static void main(String args[]) {
  j12swingappguimenu app = new j12swingappguimenu();
  app.init();
  app.start();
 }

 public void init() {
  AppletContext ac = null;
  try{ac = getAppletContext();}
  catch(NullPointerException npe){}
  new j12swingappguimenuFrame(ac);
 }
}

class j12swingappguimenuFrame extends JFrame // broken to fit 
    implements ActionListener {              // on page
 JMenuBar mb = new JMenuBar();
 JMenu file = new JMenu("File");
 JMenu edit = new JMenu("Edit");
 JMenu view = new JMenu("View");
 JMenu help = new JMenu("Help");
 JMenuItem fileOpen = new JMenuItem("Open...");
 JSeparator separator = new JSeparator();
 JMenuItem fileSaveAs = new JMenuItem("Save As...");
 JMenuItem editCut = new JMenuItem("Cut");
 JMenuItem editCopy = new JMenuItem("Copy");
 JMenuItem editPaste = new JMenuItem("Paste");
 JMenuItem helpAbout = new JMenuItem("About...");
 AppletContext ac;

 j12swingappguimenuFrame(AppletContext ac) {
  super();
  this.ac = ac;

  /* Components should be added to the container's 
     content pane */
  Container cp = getContentPane();

  /* Add menu items to menus */
  file.add(fileOpen);
  file.add(separator);
  file.add(fileSaveAs);
  edit.add(editCut);
  edit.add(editCopy);
  edit.add(editPaste);
  help.add(helpAbout);

  /* Add menus to menubar */
  mb.add(file);
  mb.add(edit);
  mb.add(view);
  mb.add(help);

  /* Set menubar */
  setJMenuBar(mb);

  /* Add the action listeners */
  fileOpen.addActionListener(this);
  fileSaveAs.addActionListener(this);
  editCut.addActionListener(this);
  editCopy.addActionListener(this);
  editPaste.addActionListener(this);
  helpAbout.addActionListener(this);

  /* Add the window listener */
  addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent evt) {
    dispose(); if (j12swingappguimenuFrame.this.ac == null) 
                  System.exit(0);}}); // broken to fit on page

  /* Size the frame */
  setSize(200,200);

  /* Center the frame */
  Dimension screenDim = // broken to fit on page
    Toolkit.getDefaultToolkit().getScreenSize();
  Rectangle frameDim = getBounds();
  setLocation((screenDim.width - frameDim.width) / 2, // broken
    (screenDim.height - frameDim.height) / 2); // to fit on page

  /* Show the frame */
  setVisible(true);
 }

 public void actionPerformed(ActionEvent evt) {
  Object obj = evt.getSource();

  if (obj == fileOpen);
  else if (obj == fileSaveAs);
  else if (obj == editCut);
  else if (obj == editCopy);
  else if (obj == editPaste);
  else if (obj == helpAbout);
 }
}