-
Bug
-
Resolution: Fixed
-
P4
-
1.4.1
-
tiger
-
x86
-
linux
Name: jk109818 Date: 11/20/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-rc-b19)
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION :
Linux simia 2.4.10-4GB #1 Tue Sep 25 12:33:54 GMT 2001 i686
unknown
glibc-2.2.4-21
A DESCRIPTION OF THE PROBLEM :
The default LAF classes registered the key stroke
"typed \010" instead of "pressed BACK_SPACE" for removing
the previous character in text components.
But "typed \010" is also generated by pressing CTRL-H (on
which OSes?). As menu item accelerators are registered (and
thus consume) only for the *pressed* key event, the *typed*
action is also executed when an accelerator is registered
for CTRL-H (i.e. it also removes the character).
This is (probably) the only place where an action for a
*typed* key stroke is used at all.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute source code.
2. Press CTRL-H: The menu action listener is executed, *and*
the previous character is deleted.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;
public class CtrlH
{
public static void main(String[] args)
{
JMenuBar b = new JMenuBar();
JMenu m = new JMenu("Menu");
JMenuItem i = new JMenuItem("Action");
i.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.err.println("Action");
}
});
m.add(i);
b.add(m);
i.setAccelerator(KeyStroke.getKeyStroke("ctrl H"));
JTextArea t = new JTextArea("kmcnxmc oarqwo4r 23894 j sjasdhajkc", 5, 40);
t.setCaretPosition(t.getDocument().getLength());
JFrame f = new JFrame();
f.getContentPane().add(new JScrollPane(t));
f.setJMenuBar(b);
f.pack(); f.show();
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Execute for each text component:
{
getInputMap().put(KeyStroke.getKeyStroke("pressed
BACK_SPACE"), DefaultEditorKit.deletePrevCharAction);
getInputMap().put(KeyStroke.getKeyStroke("typed
\010"), "none");
}
("none" being some Object that is not registered for a
enabled Action in the ActionMap)
(Review ID: 164506)
======================================================================
- relates to
-
JDK-5004088 REGRESSION: Delete composed text caused insertion of erroneous text
-
- Resolved
-
-
JDK-5026508 Demo CodePointIM: should use KEY_TYPED event instead KEY_PRESSED
-
- Resolved
-
-
JDK-6249912 REGRESSION: CTRL-H menu item accelerator causes text removal in text components
-
- Closed
-