title: Java on Mac: Keyboard commands from screen menubar not executed
body: <p>Using Java 8 with Swing on a Mac, I'm having a JMenuBar in a JFrame which is placed as a screen menu bar using the system property <code>apple.laf.useScreenMenuBar</code>.</p>
  
  <p>When I open a child dialog inside this JFrame, I should be able to access my menu commands via their shortcuts. When hitting my shortcut (Command +Z) The menubar flashes, but the command is not executed. Any suggestions? </p>
  
  <p>Here a code snippet to run the problem. Pressing Command+Z in the main JFrame works and executes the action. Pressing Command +Z inside the child window doesn't work.</p>
  
  <pre><code>public class TestClass {
  
      static class MyFrame extends JFrame {
  
          public MyFrame() throws HeadlessException {
              JMenuBar menuBar = new JMenuBar();
              JMenu menu = new JMenu("menu");
              JMenuItem menuItem = new JMenuItem(new AbstractAction("action") {
                  {
                      putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
                  }
  
                  @Override
                  public void actionPerformed(ActionEvent e) {
                      System.out.println("action executed!");
                  }
              });
              menu.add(menuItem);
              menuBar.add(menu);
              setJMenuBar(menuBar);
              JButton button = new JButton("open dialog");
              add(button);
              button.addActionListener((e) -&gt; {
                  JDialog dlg = new JDialog(MyFrame.this);
                  dlg.setSize(300, 300);
                  dlg.setVisible(true);
              });
          }
  
      }
  
      public static void main(String[] args) {
          System.setProperty("apple.laf.useScreenMenuBar", "true");
          MyFrame f = new MyFrame();
          f.setSize(400, 400);
          f.setVisible(true);
      }
  
  
  }
  </code></pre>