public static boolean isUnderMainMenu(Component component) {
    if (component instanceof JBPopupMenu menu) {
      Component invoker = menu.getInvoker();
      if (invoker instanceof ActionMenu actionMenu) {
        return actionMenu.isMainMenuPlace();
      }
    }
    return false;
  }
public static boolean isUnderMainMenu(Component component)