0

I have menu accelerator for Exit as alt+f4 in java swings ,When I press alt+f4 once event is fired once ,but when i keep pressing alt+f4 event keep on firing . How to stop that?

Lucifer
  • 29,392
  • 25
  • 90
  • 143

2 Answers2

0

Short of removing your key event listener, you can't stop events being received.

Instead, your business logic needs to ignore events that it doesn't want to handle. So perhaps after receiving the first event, set a boolean flag somewhere to tell your listener to ignore subsequent events.

Duncan Jones
  • 67,400
  • 29
  • 193
  • 254
  • as its multi threaded environment so some other threads can change the value ,so is there any other way as we are using generic event – user1630055 Mar 24 '15 at 06:23
0

You can remove the key listener for a period of time using a timer. Then re-attach the listener. Also see the answer here.

Community
  • 1
  • 1
Don Srinath
  • 1,565
  • 1
  • 21
  • 32