Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: jk109818 Date: 09/10/2002 FULL PRODUCT VERSION : java version "1.4.0_01" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03) Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode) FULL OPERATING SYSTEM VERSION : Microsoft Windows 2000 [��M-^E^T��M-^HM-^P 5.00.2195] ADDITIONAL OPERATING SYSTEMS : All, this is OS/independent issue A DESCRIPTION OF THE PROBLEM : Any non-English letter (Russian, Greek, ...), don't work as button mnemonic. Applyies to keyboards which have 1:1 correspondance between locale and English keys. The problem is that using two different methods setMnemonic(VK_<Latin>) & setMnemonic('<Locale char>') we get different, but both unworkable results. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. compile & run 2. Press Alt+G 3. Press Alt+K 4. Press Alt+R EXPECTED VERSUS ACTUAL BEHAVIOR : Expected: 1. All button have underlined items on it 2. output: English Mnemonic of Russian Label works Russian Mnemonic of Russian Label works Solely English Mnemonic works Actual: 1. First button has no underlined symbol on it 2. output: English Mnemonic of Russian Label works Solely English Mnemonic works REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MnemonicTest { public static void main(String[] args){ JFrame frame = new JFrame("Mnemonic Test"); Container contentPane = frame.getContentPane(); JButton bad1 = new JButton("\u041F\u043B\u043E\u0445\u0430\u044F"); // "Bad" JButton bad2 = new JButton("\u041F\u043B\u043E\u0445\u0430\u044F"); // "Bad" JButton right = new JButton("Right"); right.setMnemonic(KeyEvent.VK_R); // Neigther of the following work correctly: // 1. bad1.setMnemonic(KeyEvent.VK_G); // Pressing Alt+�� generates VK_G keycode // Alt+G works, but �� doesn't get underlined // 2. bad2.setMnemonic('\u043B'); // Passing the character itself // Symbol gets underlined, but Alt+K (\u043B is under K) doesn't work bad1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("English Mnemonic of Russian Label works"); } }); bad2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("Russian Mnemonic of Russian Label works"); } }); right.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("Solely English Mnemonic works"); } }); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); contentPane.setLayout(new FlowLayout()); contentPane.add(bad1); contentPane.add(bad2); contentPane.add(right); frame.pack(); frame.setVisible(true); } } ---------- END SOURCE ---------- CUSTOMER WORKAROUND : add bad1.setDisplayedMnemonicIndex(0); before line 17 in the code, the leftmost button works on Alt+G and gets underlined. Please, add this RFE and mark it fixed. Or change HOWTOs, document this possibility in AbstractButton, JLabel classes. There's only a silly example for "Save As..." there. (Review ID: 163856) ======================================================================
|