Is it possible to put an actionlistener on a tab in swing? If it is please could you post a small example?
Asked
Active
Viewed 3,659 times
2
-
What do you need exactly. Do you want the action to fire if a tab is switched? – jjnguy Dec 14 '10 at 19:56
-
I think a little search is more helpful then asking here. Ask here when you cannot find a solution for the problem. Please. – khachik Dec 14 '10 at 20:00
-
I have tryed to find a solution elsewhere but have not found anything that is the reason why I asked the question. – Harry Martland Dec 14 '10 at 20:03
-
well, check [JTabbedPane](http://download.oracle.com/javase/1.5.0/docs/api/javax/swing/JTabbedPane.html) and [ChangeListener](http://download.oracle.com/javase/1.5.0/docs/api/javax/swing/event/ChangeListener.html) – khachik Dec 14 '10 at 20:10
1 Answers
2
The only way to do that is to add a javax.swing.event.ChangeListener
to the JTabbedPane itself. You might have to keep track of the selected tab vs. previously selected tab depending on what you are doing with the state change...

Merky
- 494
- 2
- 4