title: Unable to add text to JTextArea in Java from another function
body: <p>I made a simple program in Java that contains only one text area and a button. The button is suppose to add a "text". However, it doesn't work for me.</p>
  
  <p><em>On a side note: I'm trying to keep my functions as short as possible. (I don't want a function with too many line of codes)</em></p>
  
  <p>First, I create the JFrame</p>
  
  <pre><code>private static void createFrame()
  {
      //Build JFrame
      JFrame frame = new JFrame("Text Frame");
      frame.setLayout(null);
      frame.setSize(500,400);
  
      Container contentPane = frame.getContentPane();
      contentPane.add(textScrollPane());
      contentPane.add(buttonAddText());
  
      //Set Frame Visible
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
  }
  </code></pre>
  
  <p>Then the TextArea and the Scrollpane (for adding scrollbar)</p>
  
  <pre><code>private static JTextArea textArea()
  {
      JTextArea output = new JTextArea();
      output.setLineWrap(true); // Text return to line, so no horizontal scrollbar
      output.setForeground(Color.BLACK);
      output.setBackground(Color.WHITE);
  
      return output;
  }
  
  private static JScrollPane textScrollPane()
  {
      JScrollPane scrollPane2 = new JScrollPane(textArea());
      scrollPane2.setBounds(0, 0, 490, 250);
  
      return scrollPane2;
  }
  </code></pre>
  
  <p>And finally, the button</p>
  
  <pre><code>private static JButton buttonAddText()
  {
      JButton testbutton = new JButton("TEST");
      testbutton.setBounds(20, 280, 138, 36);
  
      testbutton.addActionListener(new ActionListener(){
          @Override
          public void actionPerformed(ActionEvent e)
          {
              //action listener here
              textArea().insert("TEXT",0);
              System.out.println("Button Tested!");
          }
      });
  
      return testbutton;
  }
  </code></pre>
  
  <p>When I click on the button, it doesn't do anything.
  I just want a text to be added in the JTextArea. Did I forget something?</p>