title: How do I make JScrollPane work properly with nested JPanels?
body: <p>I'm building a Swing application in Java using NetBeans and I have a problem with layout. My main frame contains a <code>JScrollPane</code> which contains a <code>JPanel</code> called <code>contentPanel</code> which in turn contains a <code>JPanel</code> called <code>listPanel</code>. The <code>listPanel</code> is empty when the program starts, but when the user interacts with the program an unpredictable number of smaller <code>JPanel</code>s are added to it. I've used the NetBeans GUI-builder to snap the top edge of <code>listPanel</code> to the top of <code>contentPanel</code>, and the same with the bottom edges.</p>
  
  <p>The problem I have is that when more components are added to <code>listPanel</code> the vertical scrollbar doesen't appear on my scrollpane. The <code>verticalScrollBarPolicy</code> of my scrollpane is set to <code>AS_NEEDED</code> and its <code>viewportView</code> is set to <code>contentPanel</code>. What I think I need to do is to make <code>contentPanel</code> grow when more items are added to <code>listPanel</code>.</p>