private static void makeSameSizes(final Result[] resultArray, boolean horizontal) {
    int minimum = -1;
    int preferred = -1;
    for (Result result : resultArray) {
      Dimension minSize = result.minimumSize != null || result.component == null
                          ? result.minimumSize
                          : result.component.getMinimumSize();
      Dimension prefSize = result.preferredSize != null || result.component == null
                           ? result.preferredSize
                           : result.component.getPreferredSize();
      if (minSize != null) {
        minimum = Math.max(minimum, horizontal ? minSize.width : minSize.height);
      }
      if (prefSize != null) {
        preferred = Math.max(preferred, horizontal ? prefSize.width : prefSize.height);
      }
    }

    if (minimum >= 0 || preferred >= 0) {
      for (Result result : resultArray) {
        if ((result.minimumSize != null || result.component != null) && minimum >= 0) {
          if (result.minimumSize == null) {
            result.minimumSize = result.component.getMinimumSize();
          }
          if (horizontal) {
            result.minimumSize.width = minimum;
          }
          else {
            result.minimumSize.height = minimum;
          }
        }

        if ((result.preferredSize != null || result.component != null) && preferred >= 0) {
          if (result.preferredSize == null) {
            result.preferredSize = result.component.getPreferredSize();
          }
          if (horizontal) {
            result.preferredSize.width = preferred;
          }
          else {
            result.preferredSize.height = preferred;
          }
        }
      }
    }
  }
private static void makeSameSizes(final Result[] resultArray, boolean horizontal)