Maintenance Notice

The bugs.java.com site will be undergoing maintenance on 15th Dec 2017 21:00 PST to 16th Dec 2017 1:00 AM PST.
JDK-8019282 : keyRelesed is reached even though key was NOT released
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2013-04-04
  • Updated: 2014-11-17
  • Resolved: 2013-09-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 8
8 b110Fixed
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

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

I think it should be fixed. MouseListener is often used by developers.
2013-09-19

This is an AWT issue.
2013-07-22