title: Scroll bar not working for JTextArea, why?
body: <p>I'm trying to create a scrollable text area, (much like the one i'm writing in right now as in stack overflow's one). It seems as if the scrollpane and the text area are mutually exclusive and i'd like to create a connection between them</p>
  
  <pre><code>package Notepad;
  
  import java.awt.EventQueue;
  import java.awt.Font;
  
  import javax.swing.JFrame;
  import java.awt.BorderLayout;
  
  import javax.swing.JTextArea;
  import javax.swing.JScrollBar;
  
  public class test {
  
      private JFrame frame;
      private Font f = new Font(null);
  
  
      public static void main(String[] args) {
          EventQueue.invokeLater(new Runnable() {
              public void run() {
                  try {
                      test window = new test();
                      window.frame.setVisible(true);
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
          });
      }
  
      public test() {
          initialize();
      }
  
      private void initialize() {
  
          frame = new JFrame();
          frame.setBounds(100, 100, 450, 300);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().setLayout(new BorderLayout(0, 0));
  
  
          JTextArea textArea = new JTextArea();
          frame.getContentPane().add(textArea, BorderLayout.CENTER);
          textArea.setLineWrap(true);
          textArea.setFont(f.deriveFont(40f));
  
  
          JScrollBar scrollBar = new JScrollBar();
  
          frame.getContentPane().add(scrollBar, BorderLayout.EAST);
  
  
  
      }
  
  }
  </code></pre>