java - Count number of button clicks in given time -
jbutton btnnewbutton = new jbutton("click me!"); btnnewbutton.setbounds(134, 142, 274, 77); btnnewbutton.addactionlistener(new actionlistener(){ public void actionperformed(actionevent e) { clicked++; string x=integer.tostring(clicked); textarea.settext(x); } });
i'm stuck here want create program in gui counts number of button click in specific time example timer start count number of clicks when loop stop button click not working or stop counting clicks
there 2 possible solution
1.make button clickable when timer starts , unclickable when timer stops
or
2.also u can use flag check whether timer running or not.if timer running make flag true when gets on make false. somthing below snipet
public void actionperformed(actionevent e) { if (flag) { clicked++; string x=integer.tostring(clicked); textarea.settext(x); } else { // dosomething } }
Comments
Post a Comment