private static @Nullable Component findVisible(Container parent) {
    for (int i = 0; i < parent.getComponentCount(); i++) {
      Component component = parent.getComponent(i);
      if (component.isVisible()) return component;
    }
    return null;
  }
private static @Nullable Component findVisible(Container parent)