-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.2.1
-
sparc
-
solaris_2.6
JDK1.2.1-H build : Alt+menmonic char not working when menu & menuitem have same mnemonic char. This happens only on Windows platforms. Worked fine in JDK1.2.1-G build.
Steps to simulate the problem,
1. Run the attached program.
2. There are 2 menus, 1 - First Menu and 2 - Second Menu. First Menu has menmonics for menuitems also. Second Menu does not have mnemonics set for menuitems
3. Pressing Alt+1 does not drop down the list of menuitems.
4. Pressing Alt+2 drops down the list of menuitems.
--- Sample Code ---
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class Bug extends JFrame {
public Bug() {
Container content = getContentPane();
content.setLayout(new BorderLayout());
content.add("North", createMenuBar("1 - First Menu", true));
content.add("South", createMenuBar("2 - Second Menu", false));
pack();
show();
}
public JMenuBar createMenuBar(String str, boolean bFlag) {
JMenuBar menubar = new JMenuBar();
JMenuItem menuitem;
JMenu menu = new JMenu(str);
menu.setMnemonic(str.charAt(0));
menubar.add(menu);
for(int i = 0; i < 10; i ++) {
menuitem = new JMenuItem("JMenuItem" + i);
if(bFlag)
menuitem.setMnemonic('0' + i);
menu.add(menuitem);
}
return menubar;
}
public static void main(String argv[]) {
new Bug();
}
}
--- Sample Code ---
Steps to simulate the problem,
1. Run the attached program.
2. There are 2 menus, 1 - First Menu and 2 - Second Menu. First Menu has menmonics for menuitems also. Second Menu does not have mnemonics set for menuitems
3. Pressing Alt+1 does not drop down the list of menuitems.
4. Pressing Alt+2 drops down the list of menuitems.
--- Sample Code ---
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class Bug extends JFrame {
public Bug() {
Container content = getContentPane();
content.setLayout(new BorderLayout());
content.add("North", createMenuBar("1 - First Menu", true));
content.add("South", createMenuBar("2 - Second Menu", false));
pack();
show();
}
public JMenuBar createMenuBar(String str, boolean bFlag) {
JMenuBar menubar = new JMenuBar();
JMenuItem menuitem;
JMenu menu = new JMenu(str);
menu.setMnemonic(str.charAt(0));
menubar.add(menu);
for(int i = 0; i < 10; i ++) {
menuitem = new JMenuItem("JMenuItem" + i);
if(bFlag)
menuitem.setMnemonic('0' + i);
menu.add(menuitem);
}
return menubar;
}
public static void main(String argv[]) {
new Bug();
}
}
--- Sample Code ---
- duplicates
-
JDK-4213634 Alt+menmonic char not working when menu & menuitem have same mnemonic char.
-
- Closed
-