title: JMenuItem triggers listener action only when JMenu is clicked afterwards
body: <p>The relevant part of my code looks like this:</p>
  <pre><code>public MenuBar(Frame f) {
          
          JMenu _file = new JMenu(&quot;File&quot;);
          JMenu _open = new JMenu(&quot;Open&quot;);
  
          JMenuItem _studenti = new JMenuItem(&quot;Studenti&quot;);
  
      _studenti.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              .
              .
              .
          }
      }
  
      _open.add(_studenti);   
      _file.add(_open);
      add(_file);
  </code></pre>
  <p>Even though the action is tied to _studenti, _file needs to be pressed before anything can happen. I read that Action is supposed to be used instead of ActionListener, but I want to avoid making that change if it's possible. If it is necessary, which change would I need to make?</p>