500 points -- NetBeans Timer start issue

Posted on 2004-11-16
Last Modified: 2012-05-05
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.
Question by:shannonrice
    LVL 92

    Expert Comment

    can u post your code
    LVL 13

    Expert Comment

    try to construct a new Timer object each time button pressed

    Author Comment

    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.

    Accepted Solution

    Question PAQ'd
    500 points refunded.

    Community Support Moderator

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    endX challenge 2 33
    Which is the latest version of Apache Tomcatl 3 21
    Systems talking to each other 5 38
    create a gui in perl 3 23
    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…
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now