Component[] list = getComponents(); if ((list != null) && (list.length > 0)) { Dimension dim = list[0].getPreferredSize(); Dimension vp = getViewportSize ();  if (dim.width < vp.width) dim.width = vp.width;  if (dim.height < vp.height) dim.height = vp.height;  ScrollPanePeer peer = (ScrollPanePeer) getPeer (); if (peer != null) peer.childResized (dim.width, dim.height);  list[0].resize (dim);  Point p = getScrollPosition(); if (p.x > dim.width) p.x = dim.width; if (p.y > dim.height) p.y = dim.height;  setScrollPosition(p); }
layout ();
doLayout(){  Component[] list = getComponents();  if ((list != null) && (list.length > 0))    {      Dimension dim = list[0].getPreferredSize();      Dimension vp = getViewportSize ();      if (dim.width < vp.width)	dim.width = vp.width;      if (dim.height < vp.height)	dim.height = vp.height;      ScrollPanePeer peer = (ScrollPanePeer) getPeer ();      if (peer != null)	peer.childResized (dim.width, dim.height);      list[0].resize (dim);      Point p = getScrollPosition();      if (p.x > dim.width)        p.x = dim.width;      if (p.y > dim.height)        p.y = dim.height;      setScrollPosition(p);    }}