GUI countdown timer in a JApplet?

Discussion in 'Java' started by Ryan Stewart, Dec 23, 2003.

  1. Ryan Stewart

    Ryan Stewart Guest

    What would be the best way to go about creating a countdown timer that shows
    the user how much time he/she has to accomplish something, then do something
    (call a method or set a flag) when the time has run out? Imagine an applet
    with a clock counting down in one corner or another. Would you use a thread
    to update the clock? Have it sleep for 250 or 500 or 1000 milliseconds then
    calculate the remaining time and display it? If so, then how do you do the
    repaint? Pass the JApplet to the thread so it can call repaint()? That seems
    messy to me. Or maybe have the thread fire an event which the applet listens
    for? I guess if I were going to do that, then I could just use one of the
    Timer classes. I can make it work, but I'd like to get some input on clean
    and efficient ways to go about it.
     
    Ryan Stewart, Dec 23, 2003
    #1
    1. Advertising

  2. Ryan Stewart wrote:

    > What would be the best way to go about creating a countdown timer that shows
    > the user how much time he/she has to accomplish something, then do something
    > (call a method or set a flag) when the time has run out? Imagine an applet
    > with a clock counting down in one corner or another. Would you use a thread
    > to update the clock? Have it sleep for 250 or 500 or 1000 milliseconds then
    > calculate the remaining time and display it? If so, then how do you do the
    > repaint? Pass the JApplet to the thread so it can call repaint()? That seems
    > messy to me. Or maybe have the thread fire an event which the applet listens
    > for? I guess if I were going to do that, then I could just use one of the
    > Timer classes. I can make it work, but I'd like to get some input on clean
    > and efficient ways to go about it.


    BTDT. Use Timer.

    Steve
     
    Steven T Abell, Dec 24, 2003
    #2
    1. Advertising

  3. Ryan Stewart

    nos Guest

    "Steven T Abell" <> wrote in message
    news:q0kGb.49195$...
    > Ryan Stewart wrote:
    >
    > > What would be the best way to go about creating a countdown timer that

    shows
    > > the user how much time he/she has to accomplish something, then do

    something
    > > (call a method or set a flag) when the time has run out? Imagine an

    applet
    > > with a clock counting down in one corner or another. Would you use a

    thread
    > > to update the clock? Have it sleep for 250 or 500 or 1000 milliseconds

    then
    > > calculate the remaining time and display it? If so, then how do you do

    the
    > > repaint? Pass the JApplet to the thread so it can call repaint()? That

    seems
    > > messy to me. Or maybe have the thread fire an event which the applet

    listens
    > > for? I guess if I were going to do that, then I could just use one of

    the
    > > Timer classes. I can make it work, but I'd like to get some input on

    clean
    > > and efficient ways to go about it.

    >
    > BTDT. Use Timer.
    >
    > Steve
    >

    and 1000 ms for the interval
     
    nos, Dec 24, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JSP countdown timer

    , Nov 1, 2005, in forum: Java
    Replies:
    4
    Views:
    14,780
  2. KennethGorelick

    Countdown Timer

    KennethGorelick, Feb 19, 2006, in forum: Python
    Replies:
    2
    Views:
    582
    KennethGorelick
    Feb 19, 2006
  3. Dirk Hagemann

    Countdown timer for different timezones

    Dirk Hagemann, Jul 6, 2006, in forum: Python
    Replies:
    1
    Views:
    476
    Marc 'BlackJack' Rintsch
    Jul 6, 2006
  4. Michael J.

    Need special kind of countdown timer

    Michael J., Aug 27, 2003, in forum: Javascript
    Replies:
    0
    Views:
    114
    Michael J.
    Aug 27, 2003
  5. Bonnett

    Countdown Timer problems

    Bonnett, Jan 14, 2004, in forum: Javascript
    Replies:
    3
    Views:
    191
    Dr John Stockton
    Jan 15, 2004
Loading...

Share This Page