something like a time-listener

Posted on 2000-01-13
Medium Priority
Last Modified: 2010-04-16

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?)

Question by:spetrowitsch
1 Comment

Accepted Solution

comerm earned 200 total points
ID: 2349663
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:


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...


Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month5 days, 22 hours left to enroll

589 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