United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8019282 : keyRelesed is reached even though key was NOT released

Details
Type:
Bug
Submit Date:
2013-04-04
Status:
Resolved
Updated Date:
2013-12-06
Project Name:
JDK
Resolved Date:
2013-09-23
Component:
client-libs
OS:
linux
Sub-Component:
java.awt
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports

Sub Tasks

Description
FULL PRODUCT VERSION :
jdk 7

ADDITIONAL OS VERSION INFORMATION :
Ubuntu 12.10

A DESCRIPTION OF THE PROBLEM :
I will include code to show the problem:
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
int diff;
if( keyCode == KeyEvent.VK_DOWN || keyCode == KeyEvent.VK_UP) {
e.consume();
diff = 1;
if( keyCode == KeyEvent.VK_DOWN) diff = -1;
if( keyIndex > 0) {
long time1 = System.currentTimeMillis();
long diff1 = time1 - currKeyTime;
IJ.showStatus( " diff =  "  + diff1 +  " , curr=  "  + currKeyTime);
if( diff1 >= 0 && diff1 < keyDelay[keyIndex]) return;
currKeyTime = time1;
}
petCtPanel1.incrSlicePosition(diff, false);
}
if( keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT) {
e.consume();
diff = 1;
if( keyCode == KeyEvent.VK_LEFT) diff = -1;
keyIndex += diff;
if( keyIndex < 0) keyIndex = 0;
if( keyIndex >= 9) keyIndex = 9;
IJ.showStatus( " Key delay =  "  + keyIndex);
}
if( keyCode == KeyEvent.VK_HOME) {
e.consume();
petCtPanel1.incrSlicePosition(1000, false);
}
}

@Override
public void keyReleased(KeyEvent e) {
currKeyTime = 0;
}
The currKeyTime gets zeroed only on the key Released event. However the show status prints it value as a fixed zero. If I comment out the command in the key Released event, everything works as expected. This leads to one conclusion, i.e. the keyReleased event is being generated even if I hold down the key and I do not release it.
This happens only in Linux. I checked it on Windows XP and on XP it works as expected. If you need to contact me use ilan.tal(at)gmail.com.
Thanks,
Ilan

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
expect it NOT to reach keyReleased when the key is not released.
ACTUAL -
reaches keyReleased always.

REPRODUCIBILITY :
This bug can be reproduced always.
                                    

Comments
Hard to create a regression test because the fix only sets a hint, which may be unsupported by X server.
                                     
2013-10-04
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/d73d3a29065c
User:  lana
Date:  2013-10-01 17:37:37 +0000

                                     
2013-10-01
URL:   http://hg.openjdk.java.net/jdk8/awt/jdk/rev/d73d3a29065c
User:  serb
Date:  2013-09-23 17:27:27 +0000

                                     
2013-09-23
I think it should be fixed. MouseListener is often used by developers.
                                     
2013-09-19
I already have a fix and it is on a review.
                                     
2013-09-19
Alexander, what is effort scope (in b.days) to implement it?
Further, we will consider to defer of fix
                                     
2013-09-19
This is an AWT issue.
                                     
2013-07-22



Hardware and Software, Engineered to Work Together