I'd like to track the focus for all components in my Java application. I registered a method which works for most of the components, but it does not work for changing tabs. Here's the code:
FocusManager.getCurrentManager().addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
System.out.println(evt.getPropertyName() + " " + evt.getNewValue());
}
}
If I change a tab in a JTabbedPane, it will not cause a message to be printed. I suspect that this is due to the JTabbedPane focus not being changed (as clicking on a different tab may mean that it still belongs to the parent JTabbedPane).
Is there a workaround for this or does anyone know of a save method to track focus changes in Java that works also for tabs being changed?
Cheers, Max