JDK-4200559 : setMnemonic not consuming key...
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-01-05
  • Updated: 1999-02-17
  • Resolved: 1999-02-17
Related Reports
Duplicate :  
Description

Name: dbT83986			Date: 01/04/99


I don't know if this bug existed before, but my application echoes the Mnemonic into my JTextField.

Here is the JDK1.2 code:
------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class SimpleExample extends JPanel 
{
    static JFrame frame;

    public SimpleExample() 
    {
        JButton _testButton = new JButton( "Test" );
        _testButton.setMnemonic('T');

        add(_testButton);
        add(new JTextField(10));
    }

    public static void main(String s[]) 
    {
        SimpleExample panel = new SimpleExample();

        frame = new JFrame("SimpleExample");
        frame.addWindowListener(new WindowAdapter() 
        {
            public void windowClosing(WindowEvent e) 
                        {System.exit(0);}
        });

        frame.getContentPane().add("Center", panel);
        frame.pack();
        frame.setVisible(true);
    }
}
--------------------
It can be reproduced by setting focus on JTextField,
then press <ALT-T>, it echoes 't' in the JTextField.

***
(Review ID: 49034)
======================================================================

Comments
EVALUATION The JDK1.2 win32 implementation of key typed events has become more broken to match the solaris implementation. The key typed events should NOT be generated to unprintable characters such as ALT-T. Since the modifiers are now not sent with the event there is no way to filter them at the java level. This is an AWT bug, with no workaround at the java level. timothy.prinzing@eng 1999-02-08 Closing this as a duplicate of 4159610, since they have the same cause. eric.hawkes@eng 1999-02-17
08-02-1999