Say I have a JTabbedPane with ChangeListener
JTabbedPane tabbedPane = new JTabbedPane(); // Add few tabs ..... ..... tabbedPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent changeEvent) { // How to determine if the changeEvent was fired because of a tab remove/add ? } });
and somewhere I do
tabbedPane.removeTabAt(2);
and somewhere else
tabbedPane.add(panel, 0);
Now I need to activate ChangeListener, is there a way to determine inside the listener if it was called due to the remove / add tab?
EDIT: I basically try to perform some actions only when the user switches between tabs, and not when adding or removing.
source share