This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
Author

Serious Problem with Double click of JButton..

Khalid Shafquat
Greenhorn

Joined: Aug 09, 2002
Posts: 6
Developers,
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
Tom
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Serious Problem with Double click of JButton..
 
Similar Threads
Pressing ENTER when Button is selected doesnt fire buttonActionPerformed...
Disabling a button for a few seconds
Changing KeyBindings in GUIs
JTable question - URGENT
Multiple request due to double click