Forums Register Login

How to ignore more than one ActionEvents

+Pie Number of slices to send: Send
A JButton has an ActionListener registered to it.

When handling low-level MouseEvents one can intercept double-clicks and prevent them from doing anything. But how can one do the same thing with higher-level ActionEvents? Multiple ActionEvents are generated with multiple clicks.

In case the answer is to take care of this by writing your own MouseEvent handlers to consume double-clicks, does one have to handle multiple-clicks in all methods of MouseListener?

Thanks
+Pie Number of slices to send: Send
Why don't you store the time, when your action listener code executes (by a call to System.currentTimeInMillis()). Each execution you check that the time is at least, say 500 milliseconds later than the last execution, and if not ignore the event.

D.
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 775 times.
Similar Threads
how to highlight(change color) of the button and its neighbours when it is clicked
XML generation for data in a table
JButton in JTable
How can I make an executable file?
open new window
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:46:49.