title: Why add method invoked from ActionListener class doesn't add an element to collection? Java
body: <p>Ok, here's my GUI class (shorted)</p>
  
  <pre><code>public class GUI {
  private DataContainer dataContainer;
  
  public GUI(DataContainer dataContainer){
      this.dataContainer = dataContainer;
      initGUI();
  }
  
  class RegisterListener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent e){
          String message;
          String firstName = registerPanelFirstNameTextField.getText();
          String lastName = registerPanelLastNameTextField.getText();
          String login = registerPanelLoginTextField.getName();
          String password = registerPanelPasswordTextField.getText();
          String adress = registerPanelAdressTextField.getText();
          Client client = new Client(firstName, lastName, login, password, adress);
          boolean registerCheck = dataContainer.registerClient(client);
          if (registerCheck) {
              message = "SUCCES!";
          } else {
              message = "FAILURE!";
          }
          JOptionPane.showMessageDialog(new JFrame(), message);
      }
  }
  </code></pre>
  
  <p>And here's my DataContainer class (also shorted):</p>
  
  <pre><code>public class DataContainer implements Subject {
  
  public boolean workingStatus = true;
  private List&lt;Client&gt; clientList = new ArrayList&lt;&gt;();
  private List&lt;Auction&gt; auctionList = new ArrayList&lt;&gt;();
  private List&lt;Observer&gt; observersList = new ArrayList&lt;&gt;();
  
  public boolean registerClient(Client client) {
      String testLogin = client.getLogin();
      boolean isClientOnList = isClientOnList(testLogin);
      if (isClientOnList) {
          return false;
      } else {
          addClientToList(client);
          return true;
      }
  }
  
  private void addClientToList(Client client) {
      clientList.add(client);
      System.out.println(clientList);
  }
  </code></pre>
  
  <p>And here's my question - why method invoked from register listener gives empty collection. SysOut prints <code>[null]</code>. I have used JUnit and reflection to directly test <code>addClientToList()</code>, and it works, but it simply doesn't when clicking the button. And yes, in my class I created new <code>DataContainer</code> object, and passed it to GUI constructor.</p>