title: How to set scroll to the top - JPanel that has multiple JTextareas inside Jscrollpane
body: <p>I have a JPanel in a JScrollPane.
  The JPanel contains multiple JTextAreas vertically.</p>
  
  <p>I like to keep the scroll of the scrollpane to the top whenever the page is refreshed.
  Currently, the scroll always starts from the bottom.</p>
  
  <p>this is my current code and it doesn't work..</p>
  
  <pre><code>    panel.invalidate();
      panel.revalidate();
      panel.repaint();
      SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
              ((JPanel) panel).setLocation(new Point(0, 0));
          }
      });
  </code></pre>
  
  <p>I've also tried adding this code below to scrollpane, but it doesn't work..</p>
  
  <pre><code>scrollPanel.getViewport().setViewPosition( new Point(0, 0) );
  </code></pre>
  
  <p>I've looked into other stackoverflow questions and they use Jtextarea inside Jscrollpane (they solved it using setCaretPosition(0), however I can't use the same function to the panel). In my case, there is an extra layer.</p>
  
  <p>How can I solve this..?</p>
  
  <p>EDIT**</p>
  
  <p>Based on advice from Pavlo Viazovskyy, I've also tried this below and it still doesn't work for me.. :(</p>
  
  <pre><code>    javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
              scrollPane.getVerticalScrollBar().setValue(0);
          }
      });
  </code></pre>