Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

JButton feedback

Can I get some ideas about how to combat a user repeatedly clicking a button effectively launching a DOS attack on the app! How can I limit the number of clicks (within a reasonable time frame of course) to prevent this happening?
0
krakatoa
Asked:
krakatoa
  • 2
2 Solutions
 
aviadbdCommented:

Cant you just have a member, "clickButton = false" set to "true" when teh button is clicked, and check if its false before starting the action?
0
 
aviadbdCommented:

You can also inherit JButton and override the fireActionPerformed() and fireItemStateChanged() methods, to fire only once per limited time frame, or at all.

AviadBD.
0
 
krakatoaAuthor Commented:
I'll give both of these some thought. ;)
0
 
Mayank SAssociate Director - Product EngineeringCommented:
You could do it in the actionPerformed () method itself. Maintain a record of the last-time when the button was clicked. Use getSource () to check if the button-source is same and search for its last-click-time. If the current-time is within some predefined time-frame, ignore the click and exit the method.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now