Creating a Menu for a Frame

Main.java:

import java.awt.*;
import java.awt.event.*;

class MenuTest extends Frame implements ActionListener
{
   MenuBar menu=new MenuBar();
   Menu menuFile=new Menu("File");
   MenuItem menuFileQuit=new MenuItem("Quit");
 
   public static void main(String args[]) {
      MenuTest window=new MenuTest();
      window.show();
   }
 
   public MenuTest() {
      setMenuBar(menu);
      menu.add(menuFile);
      menuFile.add(menuFileQuit);
      menuFileQuit.addActionListener(this);
   }
  
   public void actionPerformed(ActionEvent e)
   {
      if (e.getSource()==menuFileQuit)
      {
         System.exit(0);
      }
   }
}