title: JButton in separate class won't change JTextField(Area) text in different class
body: <p>I have a <code>JFrame</code> which contains 3 <code>JPanels</code> (each in a separate class). The first <code>JPanel</code> contains two <code>JTextFields</code> in which I write the name of the file to be read from and the condition to be fulfilled respectively. This doesn't really affect my question, so let's move on. </p>
  
  <p>The second <code>JPanel</code> has a <code>JTextArea</code>.</p>
  
  <p>The third <code>JPanel</code> has two <code>JButtons</code> (Load, Sort) which are supposed to load a list of entries that suffice the condition from the first <code>JPanel</code> and then reorganize them according to some rules (respectively). </p>
  
  <h2>THE PROBLEM:</h2>
  
  <p>Ok so, the first class is the JFrame class in which i just do the standard look and feel of the window.</p>
  
  <p>The second class is the first <code>JPanel</code> with two <code>JTextFields</code>.</p>
  
  <p>I won't give code for this one because the second <code>JPanel</code> code is shorter and has the same problem so I imagine that the same solution would apply.</p>
  
  <p>Third class contains the <code>JTextArea</code> in which I should display certain entries from the text-file.</p>
  
  <p>Code:</p>
  
  <pre><code>public class SecondPanel extends JPanel {
  
      JPanel panel;
      JTextArea lista;
  
      public SecondPanel() {
  
          panel = new JPanel();
          list = new JTextArea("List");   
          list.setPreferredSize(new Dimension(200, 150));
          this.add(list);
  
      }
  
  }
  </code></pre>
  
  <p>Moving on, the fourth class contains the <code>Jbuttons</code> and the ActionListener(Button listener). Ok so here is the part of the code from the button listener class
  CODE:</p>
  
  <pre><code>private class ButtonListener implements ActionListener {
      SecondPanel secondPanel = new SecondPanel();
      FirstPanel firstPanel = new FirstPanel();
      @Override
      public void actionPerformed(ActionEvent e) {
  
          if(e.getActionCommand().equals("Load")) {
              //calls method that loads data from the text in a firstPanel field
              loadData(firstPanel.theFile.getText());
              for(int i = 0; i&lt; students.length; i++) {
  
                  if(students[i]!=null) {
                      // doesn't write anything tried with .setText etc.
                      secondPanel.list.append(students[i]+"\n");
  
                  }
  
              }
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>So the program won't get text  when i type in the <code>JTextField</code> designated for the file path. And when i do it manually in the code, It won't write the changes to the list on the Window (JTextArea). But when i <code>System.out.print</code> to the console it prints the changes and lists entries correctly as well as any <code>setText</code> changes I make. It just won't write or read to and from the Window.. </p>
  
  <p>What should I do?</p>