Interestingly, if it could be determined that the user left a specific tab. For example, we have 2 tabs: "omg" and "lol". The current tab is omg. I want to know that the user has switched from "omg" to "lol"
By adding a change listener to JTabbedPane, you will know when the tab changes.
JTabbedPane
Update: Added tab index tracking
tabbedPane.getModel().addChangeListener(new ChangeListener() { int lastTabIndex = -1; public void stateChanged(ChangeEvent e) { int newIndex = tabbedPane.getSelectedIndex(); if (lastTabIndex == 1 && newIndex == 2) { //or whatever check/combination of checks you would like //switched from tab 1 to tab 2! } //or just check for leaving tab 1 if (lastTabIndex == 1) { //left tab 1! } //etc lastTabIndex = newIndex; } });
, , , JTabbedPane setSelectedIndex (int). , GOING , , . super.setSelectedIndex(int), ( , ).