Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

JButton feedback

Posted on 2004-09-11
4
246 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ForLoop Example 3 52
iterator/ListIterator approach 17 39
How to execute a Python program and gather return output in Java 2 40
CSV file parsing thru Java 13 34
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

809 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