JDK-8008366 : [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7u40
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2013-02-18
  • Updated: 2015-11-26
  • Resolved: 2013-04-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u40Fixed 8 b89Fixed
Related Reports
Duplicate :  
Relates :  
Description
test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java test fails if the keystroke is changed to KeyEvent.VK_DELETE and called twice. See attached modified version of ActionListenerCalledTwiceTest for details.
Comments
javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java PASSED under JDK 8 b132 on MacOS, Linux, Solaris, Windows. Closed issue as Fixed/Verified.
11-03-2014

Test fails for JDK 7u4 too.
26-02-2013

Please provide "Introduced In Release" information. Is it from 7u4?
19-02-2013

Note that above test works fine with JDK 6u38.
18-02-2013

The test fails because the following code in CMenuItem.m does not work correctly: NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent]; if ([currEvent type] == NSKeyDown) { NSString *menuKey = [sender keyEquivalent]; NSString *eventKey = [currEvent charactersIgnoringModifiers]; if ([menuKey isEqualToString:eventKey]) { return; } } 'menuKey' is not equal to 'eventKey' in case of KeyEvent.VK_DELETE. menuKey is NSDeleteCharacter, but eventKey is NSDeleteFunctionKey. So the following naive patch fixes the test: diff -r c1304eb051f6 src/macosx/native/sun/awt/CMenuItem.m --- a/src/macosx/native/sun/awt/CMenuItem.m Thu Feb 14 11:44:09 2013 -0800 +++ b/src/macosx/native/sun/awt/CMenuItem.m Mon Feb 18 09:36:44 2013 +0100 @@ -277,7 +277,7 @@ case java_awt_event_KeyEvent_VK_TAB : macKey = NSTabCharacter; break; case java_awt_event_KeyEvent_VK_ENTER : macKey = NSCarriageReturnCharacter; break; case java_awt_event_KeyEvent_VK_BACK_SPACE : macKey = NSBackspaceCharacter; break; - case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteCharacter; break; + case java_awt_event_KeyEvent_VK_DELETE : macKey = NSDeleteFunctionKey; break; case java_awt_event_KeyEvent_VK_CLEAR : macKey = NSClearDisplayFunctionKey; break; case java_awt_event_KeyEvent_VK_AMPERSAND : macKey = '&'; break; case java_awt_event_KeyEvent_VK_ASTERISK : macKey = '*'; break; Unfortunately keyEquivalent for NSDeleteFunctionKey is empty when displayed in NSMenuItem. So this simple fix cannot be used and NSDeleteFunctionKey would probably need some special treatment, like converting it to NSDeleteCharacter in handleAction: method.
18-02-2013

Test case.
18-02-2013