title: How to Add text to JTextArea
body: <p>Im creating a programme using java. I want the user to enter some text, then push the button so the text entered shows in the label. However, I have 2 problems. First, the text are isn´t displaying when I execute the app. Second, I don´t know how to allow the user to type in the area. Im new in java so that´s why Im asking. Here is the code. Thank you.</p>
  <pre><code>import javax.swing.*;
  import java.awt.event.*;
  
  
  
  class Boton extends JFrame implements ActionListener {
      JButton boton;
      JTextArea textArea = new JTextArea();
      JLabel etiqueta = new JLabel();
  
  
      public Boton() {
          setLayout(null);
          boton = new JButton(&quot;Escribir&quot;);
          boton.setBounds(100, 150, 100, 30);
          boton.addActionListener(this);
          add(boton);
      }
  
      @Override
      public void actionPerformed(ActionEvent e) {
          if (e.getSource() == boton) {
              try {
                  String texto = textArea.getText();
                  etiqueta.setText(texto);
                  Thread.sleep(3000);
                  System.exit(0);
              } catch (Exception excep) {
                  System.exit(0);
              }
          }
      }
  }
  
  public class Main{
      public static void main(String[] ar) {
          Boton boton1 =new Boton();
          boton1.setBounds(0,0,450,350);
          boton1.setVisible(true);
          boton1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
  }
  </code></pre>