-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: bsC130419 Date: 06/12/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, interpreted mode)
If a frame has no component in its content pane the menus cannot be opened with
their defined mnemonics. So the application cannot be used with keyboard only.
import javax.swing.*;
import java.awt.*;
public class JDC2 extends JFrame{
JDC2(String title){
super(title);
init();
setSize(200, 200);
}
protected void init(){
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Test");
menu.setMnemonic('T');
menu.add(new JMenuItem("Subtest", 's'));
menuBar.add(menu);
setJMenuBar(menuBar);
}
public static void main(String [] args){
try{
UIManager.setLookAndFeel(new
com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
JFrame frame = new JDC2("Mnemonic Test");
Dimension screenSize =
Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
frame.setLocation((screenSize.width - frameSize.width) /
2, (screenSize.height - frameSize.height) / 2);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
catch(Exception ex){
ex.printStackTrace();
System.exit(0);
}
}
}
(Review ID: 126265)
======================================================================
- duplicates
-
JDK-4389332 Focus owner is null for applications which have menus only.
- Resolved