private int getPreferredHeightByWidth(int width) {
    if (myCachedPreferredSize != null && myCachedPreferredSize.width == width) {
      return myCachedPreferredSize.height;
    }
    setSize(width, Short.MAX_VALUE);
    Dimension result = getPreferredSize();
    myCachedPreferredSize = new Dimension(width, result.height);
    return myCachedPreferredSize.height;
  }
private int getPreferredHeightByWidth(int width)