Learn how to a build a cloud-first strategyRegister Now

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

500 points -- NetBeans Timer start issue

I have a problem with the NetBeans timer bean.  
For example timer1 is started when a user clicks a button on the screen - the  button's event handler calls timer1.start().  That works fine.
After the timer1 runs for 10 seconds, code inside the timer's event handler issues a timer1.stop();

Then the user will click on the button which issues the time1.start() again - but timer1 does not start.  There is no error - but timer1 never starts running again and never fires off its event handler.

I have tried timer1.restart();  -- netBeans said it is not a valid method.

Please help.
0
shannonrice
Asked:
shannonrice
1 Solution
 
objectsCommented:
can u post your code
0
 
petmagdyCommented:
try to construct a new Timer object each time button pressed
0
 
shannonriceAuthor Commented:
I figured out a way around this problem.

Inside the timer1's event handler - Instead of issuing a timer1.stop() when I want to disable the timer, I do timer1.setOnceOnly(true)

since the code is in the even handler, it considers it the one time it should run, and the timer pauses.

later when the button calls timer1.start()  it works!!

I doesn't make any sense to me why timer1.stop() makes it so I can no longer restart it.  It must be that issuing the timer1.stop() within the timer1's event handler stops the thread that listens to a start() command.  So that it is no longer possible to restart it.
0
 
CetusMODCommented:
Question PAQ'd
500 points refunded.

CetusMOD
Community Support Moderator
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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