The moose likes Swing / AWT / SWT and the fly likes Serious Problem with Double click of JButton.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Serious Problem with Double click of JButton.." Watch "Serious Problem with Double click of JButton.." New topic

Serious Problem with Double click of JButton..

Khalid Shafquat

Joined: Aug 09, 2002
Posts: 6
im having some serious kind of problem , with JButton Double click . what i need when some user double clicks (or by pressing enter key very fast 2 times ) the action behind the listener for that button is executed two times that is not desied because it has some financial transactions behind it and aloowing user pressing button two times means mess up with the database and some serious situation ..
I have tried almost every thing by disabling the button for certain period and ....blaaah blaah by applying diff flags in the code ...but what i want is SOME GENERIC solution for this coz we have a lots of GUIs (more than 500) in the application and atleast there are 2 buttons present on each screen.
So please help us out in this problem and let me know if any one have any solution about the problem.
I will be thankful to the person /Team /Organization.
Khalid Shafquat
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Khalid,
Instead of attaching an ActionListener to the JButton, you might try attaching a MouseListener instead and do something like this:

Hope this helps,
Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Thomas Suer
Ranch Hand

Joined: Sep 03, 2001
Posts: 50
What about disabling the button immediately after the user clicks on it the first time? And after executing the task you could enable the button again...
Hope that helps
I agree. Here's the link:
subject: Serious Problem with Double click of JButton..
It's not a secret anymore!