title: How to print text to a text area
body: <p>I have a text area where I want messages to be displayed in my game and I'm wondering how I would go about making a method that would print a text to the text area. Here is my GUI class:</p>
  
  <pre><code>package com.erikbalen.rpg;
  import com.erikbalen.core.*;
  import java.awt.*;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.*;
  
  public class Gui extends JFrame implements ActionListener {
  
  /**
   * 
   */
  private static final long serialVersionUID = -384241835772507459L;
  private JLabel playerInfo;
  private JTextField textField;
  private final static String newline = "\n";
  private JTextArea textArea;
  private JScrollPane scrollPane;
  
  public Gui(Player currentPlayer) {
      super("Erik's RPG");
      setLayout(new FlowLayout());        
      playerInfo = new JLabel(
         "&lt;html&gt;Health = " + currentPlayer.getHealth() 
                 + " | " + "Mana = " + currentPlayer.getMana() + "&lt;/html&gt;");  
      playerInfo.setBorder(BorderFactory.createTitledBorder(
                 currentPlayer.getName()));
      textField = new JTextField(20);
      textField.addActionListener(this);
      textArea = new JTextArea(5, 20);
      scrollPane = new JScrollPane(textArea); 
      textArea.setEditable(false);
  
      add(playerInfo);
      add(textArea);
      add(textField);
      add(scrollPane);        
  }
  
  public void actionPerformed(ActionEvent textBox) {
          String text = textField.getText();
          textArea.append(text + newline);
          textArea.setCaretPosition(textArea.getDocument().getLength());
          textField.selectAll();          
  }   
  }
  </code></pre>
  
  <p>So basically I want to make a method that's like:</p>
  
  <pre><code>public void printTextField(String text) {
      //print text to Gui.textArea
  }
  </code></pre>