title: ScrollPane in TextArea
body: <p>Here is part of my code:</p>
  
  <pre><code> JFrame window = new JFrame();
   JPanel panel = new JPanel();
   JTextArea text = new JTextArea();
   JScrollPane scroll = new JScrollPane(text);  
  
   private Window()
   {
   createWindow();
   }
  
   public void createWindow()
   {
   window.setLayout(null);
   window.setVisible(true);
   panel.setVisible(true);
   text.setBounds(20, 100, 320, 270);
   }
  
   public void update2(String employee) 
   {      
      text.setText(null);
      try
      {
      scanner = new Scanner(employee);
      }catch(Exception e){
      e.printStackTrace();
      }
      while(scanner.hasNextLine())
      {
      String line = scanner.nextLine();
      text.append(line+"\n");
      }
      revalidate();   
      }
  </code></pre>
  
  <p>I'm wondering how to add scroll bar to TextArea "text". It's a database app and it sends String of data to TextArea. I want the app to show scrollbar (vertical or horizontal) if necessary - too many Strings in TextArea. I have been trying many things but nothing works. Constructor has to be private because I'm using Singleton.</p>