JDK-4187822 : ctrl and meta KeyStrokes don't work
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-11-06
  • Updated: 1999-09-17
  • Resolved: 1999-09-17
Related Reports
Duplicate :  
Description

Name: tb29552			Date: 11/06/98


/*
If you use CTRL_MASK or META_MASK in
a KeyStroke, the accelerator never triggers.
CTRL_SHIFT works, though.


*/
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import javax.swing.*;
import java.text.*;

class SetAccel {
    public static void main(String[] args) {
        JFrame frame = new JFrame();
        JMenuBar menuBar = new JMenuBar();
//
        JMenu menu = new JMenu("Menu");
        menu.setMnemonic('M');

        JMenuItem item = new JMenuItem("Item");
        item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, KeyEvent.CTRL_MASK));
        menu.add(item);
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                System.out.println(e);
            };
        });
//
        menuBar.add(menu);

        frame.setJMenuBar(menuBar);

        frame.getContentPane().add(new JButton("Button"), BorderLayout.CENTER);
        frame.pack();
        frame.setSize(300, 300);
        frame.setVisible(true);
    }
}

(Review ID: 42224)
======================================================================

Comments
EVALUATION Georges - if this is a general keyboard ui issue, please reassign to hania. jeff.dinkins@Eng 1998-11-11 This seems to work unless the button has focus. In any case, I think it is a general keyboard/focus issue, rather than anything specific to Menus, so I'm turning it over to Hania. georges.saab@Eng 1998-11-18 This has to do with the Focus Manager's interaction with ctrl-i, which is a tab character. It's a duplicate of 4151025, so I am clossing it as such. hania.gajewska@Eng 1999-09-17
18-11-1998