Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7179290

[macosx] JMenuItem kicks an action 2 times with single key input.

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_05"
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.7.4

      A DESCRIPTION OF THE PROBLEM :
      The JMenuItem calls actionPerformed method of the action class 2 times if the accelerator key with the command key mask is set and the Mac's screen menu bar is used.


      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1, Execute the source code included.
       java MenuTestFrame

      2, Push Command+n

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      It should output only one number.
      ACTUAL -
      It outputs 2 numbers.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.event.ActionEvent;
      import java.awt.event.KeyEvent;

      import javax.swing.AbstractAction;
      import javax.swing.JFrame;
      import javax.swing.JMenu;
      import javax.swing.JMenuBar;
      import javax.swing.JMenuItem;
      import javax.swing.KeyStroke;


      public class MenuTestFrame extends JFrame{
      public MenuTestFrame() {
      JMenuBar menuBar = new JMenuBar();
      JMenu menu = new JMenu("test");
      JMenuItem item = new JMenuItem(new TestAction());

      item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.META_MASK));
      menuBar.add(menu);
      menu.add(item);
      this.setJMenuBar(menuBar);
      }

      class TestAction extends AbstractAction {
      public TestAction() {
      super("test");
      }

      @Override
      public void actionPerformed(ActionEvent arg0) {
      System.out.println(System.currentTimeMillis());
      }

      }

      public static void main(String[] args) {
      System.setProperty("apple.laf.useScreenMenuBar", "true");
      MenuTestFrame frame = new MenuTestFrame();
      frame.pack();
      frame.setVisible(true);
      }
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              rupashka Pavel Porvatov (Inactive)
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: