private static Dimension getPreferredScrollableViewportSize(Component view) {
    if (view instanceof JList) return getPreferredScrollableViewportSize((JList)view);
    if (view instanceof JTree) return getPreferredScrollableViewportSize((JTree)view);
    if (view instanceof Scrollable) return ((Scrollable)view).getPreferredScrollableViewportSize();
    if (view instanceof JComponent) return getPreferredSizeWithoutScrollBars((JComponent)view);
    return view == null ? null : view.getPreferredSize();
  }
private static Dimension getPreferredScrollableViewportSize(Component view)