I've been trying to puzzle this out as part of a larger project I'm working on: I'm trying to set up a JFrame that will react to either the passage of time or a click.
What I want it to do is to have my program wait a short moment for a click, or after a short time move on anyway. The simplest way to explain what I'm trying to do is probably look at it as if it were a reaction test--start the test, wait a couple of seconds. If the user clicks in time, tell him how much time elapsed. If he doesn't after a second or two, don't keep waiting--terminate that and instead say "Too slow!"
However, I can't do that--if I just set up my JFrame normally, it'll hang, waiting for a click. As a last resort, I could get the system time, wait for the click (however long it takes), and then compare it to the ending system time, but I'd really like things to continue happening without needing that input.
Someone I know casually suggested using either Timer or TimerTask to do what I want to, but I couldn't parse how they work and I don't see him around a computer to get help--if those can do what I want, can you please point me at a good example or tutorial for them, beyond the download.oracle reference piece?