Accelerator keys temporarily unavailable after changin JMenuBar objects

We have an application that needs to toggle between two different JMenuBar objects depending on what the user is doing. So our primary window constructs the two menus, stores both, and switches which one it is using with setJMenuBar.
The problem is that, on Windows, the first time we switch menus, all the accelerator keys stop working until the user takes a mouse action in the frame somewhere. If the user operates any widget (like a menu item or button), or even opens a menu but doesn't click anything, all the accelerators suddenly become available.
Actions that DO cause the accelerators to become available:
- A mouse click on a widget inside this frame (as long as the click is not entirely consumed by an internal element)
- Resizing the window
- Minimizing / restoring the window
- Switching to another application and back
- Simulating any such mouse click with a Robot
Actions that DON'T cause the accelerators to become available:
- Mouse Moves
- Clicks on internal widgets that implement MouseListener
- Programmatically operating widgets with doClick(), even if clicking on that widget would re-enable the accelerators
NOTE: this seems to only affect Windows. I haven't tried it on Linux yet, but the bug does not affect Mac OS X, so it doesn't look like I'm doing anything explicitly wrong when I switch menu bars.
Has anyone else seen this, or can you suggest a fix or workaround? My current workaround is to simulate a click on the menu bar with a Robot after the first time we switch menu bars. But that's terribly kludgy and I'd like to find a better solution.
Thanks,
Evan
Edited by: IdahoEv on Jun 21, 2009 4:15 PM
Edited by: IdahoEv on Jun 21, 2009 4:16 PM

Has anyone else seen this,No.
If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

Similar Messages

Maybe you are looking for