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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -