Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issues when popup a dialog from keyReleased event

David Chen
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, there:

I just noticed a strange issue: I have a JTextField (testText) in my GUI, which registered a keyListener, when I popup a dialog in its keyReleased() function, pressing "enter" key on dialog causes keyReleased event on JTextField endlessly. However, it's ok using mouse clicking on "ok" on dialog. The same dialog works fine in keyPressed() function.

When above code running on jdk1.4.2, I pressed any key (ex. "Esc" or "Enter") key on that text field, this_keyReleased() is invoked, and a message dialog is popped up with focus on "OK" button on that dialog. So, when I pressed "Enter" key, for some reasons the keyReleased event is fired again and the same message dialog is popped up again, so, keeps pressing "Enter" key, keeps popping up the same dialog endlessly. However, moving this_keyRelease() from keyReleased() to keyPressed(), everything seems ok.
So, could any one please give me some hints how does that happen? Is that from some focus issues? or is that a bug in jdk1.4.2?

Thanks a lot in advance

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic