private static boolean hasMnemonicInBalloons(Container container, int code) { final Component parent = UIUtil.findUltimateParent(container); if (parent instanceof RootPaneContainer) { final JLayeredPane pane = ((RootPaneContainer)parent).getLayeredPane(); for (Component component : pane.getComponents()) { if (component instanceof ComponentWithMnemonics && component instanceof Container && hasMnemonic((Container)component, code)) { return true; } } } return false; }