title: JScrollPane not showing scrollbars
body: <p>I have a JPanel with a custom LayoutManager and trying to get it inside a JScrollPane, however, the scroll pane doesn't seem to know it's supposed to enable scrolling. No matter how I set preferred size of the components (that is what the javadoc for JScrollPane says it needs), it makes absolutely no difference. Here is the code:</p>
  
  <pre><code>    canvas = new JPanel();
      JScrollPane scroll = new JScrollPane();
      scroll.setViewportView(canvas);
      scroll.setPreferredSize(new Dimension(924,700));
      canvas.setPreferredSize(new Dimension(2000,2000));
  </code></pre>
  
  <p>The scrollbars don't appear. The container of the JScrollPane is set to respect its preferred size. I have checked through the debugger that the preferred size of the canvas is indeed 2000 x 2000 at all times (the LayoutManager ensures this), so what might be going on here? </p>