public static JComponent findComponentByPredicate(JComponent container, ComponentFilter pred) {
    for (Component c : container.getComponents()) {
      if (!(c instanceof JComponent)) {
        continue;
      }

      if (pred.accept((JComponent) c)) {
        return (JComponent) c;
      }

      JComponent result = findComponentByPredicate((JComponent) c, pred);
      if (result != null) {
        return result;
      }
    }
    return null;
  }
Centers the child component relative to its parent component.
java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/GuiHelper.java