Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4469090

Menu cannot be opened with mnemonic if frame has no component in content pane

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.0
    • client-libs



      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)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: