title: Get a textarea in java using JFrame
body: <p>I'm new to Java, I would like to know how can I get my textarea from the main class??</p>
  
  <p>This is my code:</p>
  
  <pre><code>public static void main(String[] args) {
      UIManager.put("swing.boldMetal", Boolean.FALSE);
  
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
          public void run() {
              createAndShowGUI();
  
          }
      });
  }
  
  
  
  private static void createAndShowGUI() {
      frame = new JFrame("Frame");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      GuiManager animator = new GuiManager();
  
      frame.add(animator, BorderLayout.CENTER);
  
      // Display the window.
      frame.pack();
      frame.setSize(800, 500);
      frame.setVisible(true);
  }
  </code></pre>
  
  <p>and GuiManager:</p>
  
  <pre><code>public GuiManager() {
      setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
  
         // .............
  
      // Create Scrolling Text Area in Swing
      JPanel panelLabel = new JPanel(); 
      panelLabel.setLayout(new FlowLayout());     // No content pane for JPanel.
      JPanel panel = new JPanel(); 
      panel.setLayout(new FlowLayout());     // No content pane for JPanel.
  
  
      JLabel ta1Label = new JLabel("Label One", JLabel.LEFT);
      ta1Label.setAlignmentX(Component.LEFT_ALIGNMENT);
  
      JTextArea ta = new JTextArea("", 10, 30);
      ta.setLineWrap(true);
      JScrollPane sbrText = new JScrollPane(ta);
      sbrText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  
      JLabel ta2Label = new JLabel("Label2", JLabel.RIGHT);
      ta2Label.setAlignmentX(Component.RIGHT_ALIGNMENT);
  
      JTextArea ta2 = new JTextArea("", 10, 30);
      ta2.setLineWrap(true);
      JScrollPane sbrText2 = new JScrollPane(ta2);
      sbrText2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
  
      panelLabel.add(ta1Label);
      panelLabel.add(ta2Label);
      panel.add(sbrText);
      panel.add(sbrText2);
  
  
  
      // Put everything together.
      add(panelLabel);
      add(panel);
      setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
  
  }
  </code></pre>
  
  <p>My goal is to redirect the output to these textarea, and for some output I need to redirect to the textarea on the left, but sometime I need to output on the textarea on the right. What would be the best solution to do that? Thank you.</p>