static void showMnemonics( boolean show, Component c ) {
		if( show == showMnemonics )
			return;

		showMnemonics = show;

		// check whether it is necessary to repaint
		if( !UIManager.getBoolean( "Component.hideMnemonics" ) )
			return;

		if( show ) {
			// get root pane
			JRootPane rootPane = SwingUtilities.getRootPane( c );
			if( rootPane == null )
				return;

			// get window
			Window window = SwingUtilities.getWindowAncestor( rootPane );
			if( window == null )
				return;

			// repaint components with mnemonics in focused window
			repaintMnemonics( window );

			// hide mnemonics if window is deactivated (e.g. Alt+Tab to another window)
			windowListener = new WindowAdapter() {
				@Override
				public void windowDeactivated( WindowEvent e ) {
					altPressedEventCount = 0;
					selectMenuOnAltReleased = false;

					// use invokeLater() to avoid that the listener is removed
					// while the listener queue is iterated to fire this event
					EventQueue.invokeLater( () -> {
						showMnemonics( false, null );
					} );
				}
			};
			window.addWindowListener( windowListener );

			lastShowMnemonicWindow = new WeakReference<>( window );
		} else if( lastShowMnemonicWindow != null ) {
			Window window = lastShowMnemonicWindow.get();
			if( window != null ) {
				repaintMnemonics( window );

				if( windowListener != null ) {
					window.removeWindowListener( windowListener );
					windowListener = null;
				}
			}

			lastShowMnemonicWindow = null;
		}
	}
Special Alt key behavior on Windows.

Press-and-release Alt key selects first menu (if available) and moves focus
temporary to menu bar. If menu bar has focus (some menu is selected),
pressing Alt key unselects menu and moves focus back to permanent focus owner.
flatlaf-core/src/main/java/com/formdev/flatlaf/MnemonicHandler.java