JDK-4758891 : RFE: Want to use German characters (��,��,��,��) as mnemonics
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2002-10-07
  • Updated: 2004-09-16
  • Resolved: 2004-09-16
Related Reports
Duplicate :  
Relates :  
Description

Name: rmT116609			Date: 10/07/2002


FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1.-b21)
Java HotSpot(TM) Client VM (build 1.4.1.-b21, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows XP Home German-Version 5.1.2600

ADDITIONAL OPERATING SYSTEMS :
Win2000, WinNT


EXTRA RELEVANT SYSTEM CONFIGURATION :
you'll need a german keyboard

A DESCRIPTION OF THE PROBLEM :
Can't use the German charactes M-^D��M-^RM-^^ as mnemonics. They become underlined, but don't work.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. run the program I've pasted below
2. press ALT+��
3. the menu should open, but nothing happens

EXPECTED VERSUS ACTUAL BEHAVIOR :
after pressing ALT+�� the menu should open but nothing
happens

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.event.*;
import javax.swing.*;

public class mnemonicRFE
{
  public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setSize(200,100);
    JMenuBar mb = new JMenuBar();
    f.setJMenuBar(mb);

    JMenu m = new JMenu("abc ����M-^[M-^^");
    m.setMnemonic('��');
    mb.add(m);

    JMenuItem mi = new JMenuItem("menuitem");
    m.add(mi);

    f.show();
    try { Thread.sleep(4000); }
    catch(Exception e) {}

    System.exit(0);
  }
}
---------- END SOURCE ----------
(Review ID: 165109) 
======================================================================

Comments
EVALUATION Name: pzR10082 Date: 04/25/2003 Currently we use virtual key codes to obtain KeyStroke object that is used to trigger a menu item action. We should instead use getKeyStroke(Character keyChar, int modifiers) in order to support national alphabets like German or Cyrillic. ###@###.### ====================================================================== Name: apR10133 Date: 05/08/2003 We couldn't just replace the key code with char for getting KeyStroke. But we could try to get the keyMap by char if there is nothing mapped on KeyStroke obtained by key code. This way has the only restriction: we shouldn't assign as mnemonic the symbols that belong to different alphabets, but placed on the same key on keyboard. ###@###.### ====================================================================== Close this bug as a duplicate of 4239028. ###@###.### 2004-09-16
17-09-2004

SUGGESTED FIX Name: apR10133 Date: 05/08/2003 ------- KeyboardManager.java ------- *** /tmp/sccs.Rmaq3e Thu May 8 14:06:54 2003 --- KeyboardManager.java Thu May 8 13:23:48 2003 *************** *** 195,200 **** --- 195,205 ---- if (keyMap != null) { // this container isn't registered, so bail Object tmp = keyMap.get(ks); + if (tmp == null) { + // Try to locate the KeyStroke by char. + ks=KeyStroke.getKeyStroke(e.getKeyChar(), e.getModifiers(), !pressed); + tmp = keyMap.get(ks); + } if (tmp == null) { // don't do anything ###@###.### ======================================================================
17-09-2004