something like a time-listener

Hi.

I have a jTabbedPane, and the first registercard of it is a login-window.

When I am in the second or third registercard, and I do nothing for a while, I want to go back to the first registercard. I thought about creating a thread, which I call within each action-listener to set the time back. But - how to find out, at what time there is the timeout? (From the side of the Thread and from the side of my class?)

Thanks!
spetrowitschAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

comermCommented:
Have your main class implement the ActionListener interface. Then, in your main class, do something like this:

Timer t = new Timer(secs * 1000, this);

because you are implementing the ActionListener interface, your class should now have a method:

public void actionPerformed(ActionEvent ae)
{
   ... your code to switch back to login pane ...
}

When some activity occurs on any pane, do:

t.restart();

to prevent the timer from firing.

WARNING: the timer sends notifications back to you on a seperate thread, so your actionPerformed method needs to be concerned with thread safety. In particular, you should be carefull about modifying Swing components on anything other than the Swing notification thread. See SwingUtilities.invokeLater or SwingUtilities.invokeAndWait...

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.