In my Java Swing GUI I have a main window with JMenus and shortcuts, and the possibility to open a second window to see some detail information.
When having clicked somewhere in the the second window, the menu shortcuts no longer work -- of course, it is another window than the one where the menu resides.
How can I "forward" the key events from the second window to the main window? My first idea was to let the main window implement KeyListener
and put getJMenuBar().dispatchEvent(...)
into the relevant methods, but while thinking about that, I saw lots of Do not use KeyListeners in Swing! statements on SO.