title: How do I set the size and location of a JScrollPane?
body: <p>I'm trying to set the size and location of a <code>JScrollPane</code> in a <code>JFrame</code>, and it's <code>JViewport</code> is a <code>JTextArea</code>.</p>
  
  <p>The following is the code I am using:</p>
  
  <pre><code>private static JFrame frame = new JFrame();
  
  public static void main(String... args) {
      frame.setTitle("Friend App");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(800, 600);
      JTextArea textArea = new JTextArea();
      JScrollPane scrollPane = new JScrollPane(textArea);
      scrollPane.setLayout(null);
      scrollPane.setLocation(30, 30);
      scrollPane.setSize(new Dimension(100, 100));
      frame.add(scrollPane);
      textArea.append("test");
      frame.setVisible(true);
  
  }
  </code></pre>
  
  <p>What else am I supposed to do so I can resize and set the location of this JScrollPane? Am I using the best approach here?</p>
  
  <p>Note: <code>scrollPane.setLayout(null)</code> does nothing, <code>frame.pack()</code> is not what I want.</p>