Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
Name: krC82822 Date: 04/18/2001 [filing as RFE, based on disposition of bug # 4425284] java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C) Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode) import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MnemonicButtonTest { public static void main(String[] args){ JFrame frame = new JFrame("MnemonicTest"); Container contentPane = frame.getContentPane(); JButton change = new JButton("?ndern"); // "Change"-Button JButton other = new JButton("Other"); other.setMnemonic('O'); other.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("Other action"); } }); // Set the mnemonic char by virtual key code. // 222 is A-Umlaut's virtual key code on German keyboard (Second key right of 'L'). change.setMnemonic(222); // A-Umlaut not underlined. Keyboard shortcut works. //change.setMnemonic('?'); //change.setMnemonic('\u00C4'); // A-Umlaut's Unicode. A-Umlaut underlined. Keyboard shortcut doesn't work. change.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ System.out.println("Change action"); } }); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); contentPane.setLayout(new FlowLayout()); contentPane.add(other); contentPane.add(change); frame.pack(); frame.setVisible(true); } } (Review ID: 120839) ======================================================================
|