|
Quick Lists
|
|
Bug ID:
|
4501485
|
|
Votes
|
12
|
|
Synopsis
|
Alt-arrow keys enters strange characters in TextComponents
|
|
Category
|
java:classes_awt
|
|
Reported Against
|
1.4.1
, merlin-beta2
, merlin-beta3
|
|
Release Fixed
|
|
|
State
|
11-Closed, duplicate of 4737679,
bug
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4708221
,
4710498
,
4737679
|
|
Submit Date
|
10-SEP-2001
|
|
Description
|
java version "1.4.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)
/*
Program to illustrate the Alt-Arrow bug.
Under JDK 1.3 and earlier, if I hold down the alt key and type an arrow,
nothing happens. Nothing should happen, so this is customer .
Starting in JDK 1.4b2, I get extraneous characters when I type alt-arrow.
This may not sound like a big deal, but there are other applications that
define alt-arrow, so that makes it an easy mistake to make. It may also be a
symptom of a more serious problem with event handling.
To reproduce, run this program. Click into the JTextField, the JTextArea,
or the JEditorPane. Hold down the alt key and type any of the four arrow
keys. Under JDK 1.4b1 or earlier, nothing happens. Under JDK 1.4b2, strange
characters get inserted into the text.
*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.plaf.multi.*;
import javax.swing.plaf.basic.*;
import javax.swing.plaf.metal.*;
public class AltArrowBug extends JFrame
{
public static void main(String[] args)
{
// Uncomment a pair of lines to test under a different look and feel.
// try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); }
// catch (Exception err) { }
// try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
// catch (Exception err) { }
new AltArrowBug();
}
AltArrowBug()
{
super("Alt-Arrow Bug");
addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent evt) { System.exit(0); } } );
setBounds(20, 20, 400, 300);
String jdkvers = System.getProperty("java.version");
JTextField fld = new JTextField("This is a test. Java version = " +jdkvers);
JTextArea area = new JTextArea("This is also a test. \nJava version = " +jdkvers);
JScrollPane areaScr = new JScrollPane(area);
JEditorPane editor = new JEditorPane();
editor.setText("And this is a test. \nJava version = " + jdkvers);
JScrollPane edScr = new JScrollPane(editor);
Container cp = getContentPane();
cp.setLayout(new BorderLayout());
JPanel dualPanel = new JPanel(new GridLayout(0,1));
cp.add(fld, "North");
dualPanel.add(areaScr);
dualPanel.add(edScr);
cp.add(dualPanel, "Center");
show();
}
}
(Review ID: 131445)
======================================================================
java version "1.4.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b84)
Java HotSpot(TM) Client VM (build 1.4.0-beta3-b84, mixed mode)
In JTextField when I press ALT + PGUP appears "c".
---------------------------------------------------------------------------
import javax.swing.*;
import java.awt.event.*;
public class Test implements KeyListener{
/**
* Invoked when a key has been typed.
* See the class description for {@link KeyEvent} for a definition of
* a key typed event.
*/
public void keyTyped(KeyEvent e) {
System.out.println("key typed:"+e.getKeyChar ()+":"+e.getModifiers ());
}
/**
* Invoked when a key has been pressed.
* See the class description for {@link KeyEvent} for a definition of
* a key pressed event.
*/
public void keyPressed(KeyEvent e) {
System.out.println("key pressed:"+e.getKeyChar ()+":"+e.getModifiers());
}
/**
* Invoked when a key has been released.
* See the class description for {@link KeyEvent} for a definition of
* a key released event.
*/
public void keyReleased(KeyEvent e) {
System.out.println("key released:"+e.getKeyChar ()+":"+e.getModifiers());
}
public static void main(String [] args){
JFrame frame=new JFrame("Test");
JTextField field=new JTextField(20);
field.addKeyListener (new Test());
frame.getContentPane ().add(field);
frame.pack();
frame.setVisible(true);
}
}
------------------------------------------------------------------------------
When I press the character "c", I become the output:
key pressed:c:0
key typed:c:0
key released:c:0
When I press ALT + PGUP, I become the output :
key pressed:?:8
key pressed:?:8
key released:?:8
key released:?:0
key typed:c:0
(Review ID: 136497)
======================================================================
|
|
Work Around
|
N/A
|
|
Evaluation
|
Previous to this problem's introduction, a Swing text component's processKeyEvent was not sent a KeyEvent of type KEY_TYPED when these combinations of keys were typed. Currently, typing alt plus one of the arrow creates and sends a KEY_TYPED KeyEvent with a valid character (such as B, X, etc...). Swing processes them as any other KeyTyped. I beleive the problem is somewhere in AWT. Re-assigning.
xxxxx@xxxxx 2001-09-12
I tried this on WinNT with an AWT TextField. Spy++ reveals that when I press
Alt - LeftArrow, I get a WM_CHAR message after both keys have been released.
The result is a comma entered into the TextField.
This WM_CHAR is not sent to the TextField under 1.3 or 1.3.1.
xxxxx@xxxxx 2001-09-16
Commit to fix in Tiger.
xxxxx@xxxxx 2001-09-17
|
|
Comments
|
Submitted On 08-MAY-2002
CKX
Hi.
Same effect on ALT+HOME. The funny thing: The ALT+HOME
combination may produce different result characters
depending on the key that is released first. If I release
the HOME key first, I get a KEY-TYPED with a keyChar of 'M'
while reasing the ALT key first produces a KEY_TYPED with a
keyChar of a solid dot (password echo char on Win2K).
SDK1.4.0b92, Win2000
Regards
CKX
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |