title: JMenuBar - Hide JMenu with shortcut Ctrl+h, keystroke don't work after setVisible(false)
body: <p>I try to make an JMenuBar hide and show with the ctrl+h keystroke, i've succeed to do this for hidding the JMenu but I can't use ctrl+h to show the JMenu, here he's the code : </p>
  
  <pre><code>import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;    
  import view.Menu;
  import view.Window;
  
  public class MenuController implements ActionListener {
  
      protected Window w;
      protected Menu m;
  
      public MenuController(Window w) {
          this.w = w;
          this.m = w.getMenu();
          m.getQuit().addActionListener(this);
          m.getHide().addActionListener(this);
      }
  
      @Override
      public void actionPerformed(ActionEvent e) {
          String item = e.getActionCommand();
          if (item.equals("Quitter"))
              System.exit(0);
          if(item.equals("Masquer le menu")) {
              if(m.isVisible() == true)
                  m.setVisible(false);
              else
                  m.setVisible(true);
          }
      }    
  }
  </code></pre>
  
  <p>getHide(), give the JMenuItem who have the keystroke, if you see where he's the problem...
  Regards</p>
  
  <p>Edit : So here, the view.Menu class :</p>
  
  <p>public class Menu extends JMenuBar {</p>
  
  <pre><code>private static final long serialVersionUID = 1L;
  private JMenuItem quit = new JMenuItem();
  private JMenuItem hide = new JMenuItem();
  
  
  public Menu() {
      JMenu menu1 = new JMenu("Fichier");
  
      hide.setText("Masquer le menu");
      hide.setEnabled(true);
      hide.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK));
      menu1.add(hide);
  
      quit.setText("Quitter");
      quit.setEnabled(true);
      quit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK));
      menu1.add(quit);
  
      add(menu1);
  }
  
  public JMenuItem getQuit() {
      return quit;
  }
  
  public JMenuItem getHide() {
      return hide;
  }
  </code></pre>
  
  <p>}</p>