R
Ryan Stewart
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.
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.