Solved

JButton feedback

Posted on 2004-09-11
4
239 Views
Last Modified: 2010-03-31
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
Comment
Question by:krakatoa
  • 2
4 Comments
 
LVL 3

Expert Comment

by:aviadbd
ID: 12033577

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
 
LVL 3

Assisted Solution

by:aviadbd
aviadbd earned 75 total points
ID: 12033587

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
 
LVL 16

Author Comment

by:krakatoa
ID: 12034869
I'll give both of these some thought. ;)
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 125 total points
ID: 12038197
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question