title: How to force-refresh/repaint a JScrollPane?
body: <p>I am adding lots of components (JPanels, JLabels etc.) into a JScrollPane programagically at the start of my program based on some stuff from a database.</p>
  
  <p>It seems that this procedure is too fast for the GUI(?), so the JScrollPane does not always update correctly, i.e the scroll bars are not visible even though the inner JPanel is bigger than the visible area.</p>
  
  <p>Resizing the Window (JFrame) fixes the problem, as I assume Java is re-printing the components when they are resized.</p>
  
  <p>As a test, I have added a debug-button that I can click after the startup of the program has finished. I am trying to force the JScrollPane to "refresh" itself.</p>
  
  <p>I have tried doing:</p>
  
  <pre><code>scrollpane.repaint();
  scrollpane.validate();
  scrollpane.revalidate();
  </code></pre>
  
  <p>None of them seems to work. However, if I change the border (or any other layout related to the JScrollPane), it refreshes correctly.</p>
  
  <pre><code>scrollpane.setBorder(new LineBorder(Color.RED));
  </code></pre>
  
  <p>So I basically have 2 questions.</p>
  
  <ol>
  <li><p>What is the command for forcing the scrollpane to "refresh"? Obviously it is doing some kind of "repaint" thing when I am adding the border. How can I run that only?</p></li>
  <li><p>Is there a way of "pausing" the printing of components as they are added and resume it again after I added all the wanted components? As it is now, I basically "see" the components being added on the screen (even though it is really fast). It would be better if I can add all the components I want and THEN tell the program to print it to the screen/JFrame.</p></li>
  </ol>