title: Adding an ActionListener to JMenuItem
body: <p>I've just begun a simple GUI project, and while creating the menu bar, I ran into an error that I find to be inexplicable. I want to add an <code>ActionListener</code> to a <code>JMenuItem</code> using <code>addActionListener</code>, as I have done in the past. However, when I apply said method, Eclipse gives an error: "Syntax error on token "addActionListener", = expected after this token." My only thoughts are that perhaps <code>addActionListener</code> is being interpreted as a property rather than a method... but I have used this method in the past so I do know that it works. I am unsure of how much code I should provide, so please let me know if I should edit in more.</p>
  
  <pre><code>package com.movethehead;
  
  import javax.swing.JFrame;
  import javax.swing.SwingUtilities;
  import javax.swing.JMenuBar;
  import javax.swing.JMenu;
  import javax.swing.JMenuItem;
  
  import java.awt.event.ActionListener;
  import java.awt.event.ActionEvent;
  
  @SuppressWarnings("serial")
  public class Main extends JFrame {
  
      private final int W = 500;
      private final int H = 500;
  
      JMenuBar menuBar = new JMenuBar();
  
      JMenu file = new JMenu("File");
      JMenuItem exitItem = new JMenuItem("Exit");
      exitItem.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
                  System.exit(0);
          }
      });
  
      JMenu headMenu = new JMenu("Heads");
      JMenu bgMenu = new JMenu("Backgrounds"); 
  
      public Main() {
          setTitle("Move the Head");
          setSize(W, H);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setLocationRelativeTo(null);
  
          add(new Pnl());
          setJMenuBar(menuBar);
      } // end constructor
  
      public static void main( String[] args ) {
          SwingUtilities.invokeLater(new Runnable() {
              @Override
              public void run() {
                  Main f = new Main();
                  f.setVisible(true);
          }
      });
  } // end main()
  } // end Main
  </code></pre>