MODIFIED FROM javax.swing.ScrollPaneLayout.layoutContainer This is largely the same as ScrollPaneLayout.layoutContainer but obtains the preferred view size from the viewport rather than directly from the view so the viewport can get the preferred size from the ZScrollDirector