private static Component getComponent(Container container) {
    synchronized (container.getTreeLock()) {
      for (Component component : container.getComponents()) {
        if (component.isVisible()) return component;
      }
    }
    return null;
  }
private static Component getComponent(Container container)