JDK-7144063 : [macosx] Swing JMenu mnemonic doesn't work; hint misleading; cross symbol typed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: x86
  • Submitted: 2012-02-09
  • Updated: 2015-10-12
  • Resolved: 2012-04-05
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.
7u4 b18Fixed 8Fixed
Related Reports
Relates :  
Relates :  
Mac OS X 10.7.3 macmini4,1 standard Mac keyboard
You will see a JMenu with item providing a hint "Alt T" (alt displayed as a zigzag). You may click and get a proper action from there.

Now focus in a textfield and press Alt+t or Ctrl+Alt+t as it used to be some builds ago: there will be no action. Moreover, on Alt+t you'll see a dreadful symbol "dead" (a cross) typed in the text field! Long live Swing.

EVALUATION I titally agree that we have to raise inputMethod event for any complex character that came to the insertText routine and lowering limit of the utf8charwisth to >1 byte should solve that problem.

EVALUATION Attached a simple test case which shows the above scenario.

EVALUATION The behavior of Apple JDK is the following. When I type Alt+F, the special unicode symbol appears in the textfield and the menu gets activated simultaneously. When I type Alt+T, the special unicode symbol appears in the textfield but the menu doesn't get activated. (Other Alt+key conminations behave the first of the second way). I digged the open jdk and found the following. [AWTView insertText] is called on typing Alt+key. This is a method of NSTextInputClient protocol. Then some conditions are checked and the java CInputMethod.insertText(String) method is called. Among those conditions there's a utf8 str length check. If it's greater than 2, the java method is called. It creates an appropriate InputMethodEvent which is then posted, dispatched and the unicode symbol appears in the text field. Otherwise, the key event is delivered to CPlatformResponder where it creates a KEY_TYPED event and packes the two bytes unicode character into it. It is then treated as mnemonic and the menu is activated. Alt+F generates a utf8 symbol of two bytes size, Alt+T generates a symbol of 3 bytes. That's the difference. Simply ignoring the condition (utf8length > 2) in [AWTView insertText] makes all the Alt+key symbols appear in the text field. The menu is no longer activated. For me, this behavior looks right for Mac. (The menu gets activated by Alt+key being typed only on non-text components). I'm not sure what is the right fix though (the change I suggested is just a try).

PUBLIC COMMENTS Build: b227 closed/java/awt/swing/event/KeyEvent/MenuShortCut/JActionCommandTest