Reputation:
I overrode DefaultKeyboardFocusManager to provide some special behavior for the Alt key. However, after setting this, I notice that hitting Tab on some of my text fields does not work.
I also experimented with even calling the following on the AWT, but this still exhibited the broken Tab behavior:
KeyboardFocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager());
Why would setting the current keyboard focus manager have such bad effects?
Upvotes: 1
Views: 1055
Reputation: 1850
I just ran into this problem as well. While developing a custom KeyboardFocusManager I noticed that even calling:
KeyboardFocusManager.setCurrentKeyboardFocusManager(new DefaultKeyboardFocusManager());
would change the behavior.
It appears that some early initialization was taking place, and the fix in my case was to set the KeyboardFocusManager before I showed any UI resources. I did this at the top of my application's main() function, and then the KeyboardFocusMangers worked as expected (both the default and my custom one).
Upvotes: 2