title: JavaFX ObservableList change not updating ListView
body: <p>So I am creating a UI with JavaFX for a server controller, what it is does not matter, all that is important is that the server.getClients(); returns an ArrayList of IClients.</p>
  
  <p>I wish to display these clients (they are represented by IP but once again, this doesn't seem relevant) in a ListView. However, clients may connect at any given point in time and when this happens, they get added to the server's IClient ArrayList. When this List is updated, I want the ListView to refresh and show the new client. For some reason, I simply cannot get this to work. </p>
  
  <p>I am very new to JavaFX and I think I might be overseeing something.
  I'm very sorry if this is a duplicate or obvious, I have searched for a long time over the past couple of days but I might have overlooked a solution.</p>
  
  <p>The following code is the abbreviated version of my FXMLController for the JavaFX application:</p>
  
  <pre><code>/*imports*/
  
  public class FXMLController implements Initializable {//serverUI.FXMLController
  
  @FXML private ListView clientListView;
  /*some more (irrelevant) code*/
  
  private IServer server;
  /*some more (irrelevant) code*/
  private ObservableList&lt;IClient&gt; serverClientsObservableList;
  
  @Override
  public void initialize(URL url, ResourceBundle rb) {
      System.out.println("initialization...");
      /*some more (irrelevant) code*/
      //the server was started here
  
      // FXML Controls
      initClientListView();
  
      /*some more (irrelevant) code*/
      System.out.println("initialized");
  }    
  
  /*some more (irrelevant) code*/
  
  
  private void initClientListView() {
          System.out.println("clientListView");            
          serverClientsObservableList = FXCollections.observableList(server.getClients());
          serverClientsObservableList.addListener(new ListChangeListener&lt;IClient&gt;() {
              @Override
              public void onChanged(ListChangeListener.Change&lt;? extends IClient&gt; change) {
                  System.out.println("list change detected");
                  //is any of the followin three lines really necessary to update the ListView content?
                  serverClientsObservableList.setAll(server.getClients());
                  clientListView.setItems(null);
                  clientListView.setItems(serverClientsObservableList);
              }
          });
          clientListView.setItems(serverClientsObservableList);
  }
  
  
  
  /*some more (irrelevant) code*/
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I don't want to refresh the ListView when something in the IClients changes, nothing changes in them. I want to refresh the ListView when a NEW IClient is ADDED to the server's client list. The ListView should show the NEW IClient</p>
  
  <p>EDIT2:</p>
  
  <p>According to the suggested duplicate I tried the following, however I don't really understand what it's doing and how it works. This did not solve the problem, it gives me an error when I try to create the new Observable[]</p>
  
  <pre><code>Callback&lt;IClient, Observable[]&gt; extractor = new Callback&lt;IClient, Observable[]&gt;() {
              @Override
              public Observable[] call(IClient c) {
                  return new Observable[] {c.getNameProperty()};
              }
          };
          ObservableList&lt;IClient&gt; clientOList = FXCollections.observableArrayList(extractor);
  </code></pre>
  
  <p>Additionally: the code where I add the clients to the server. 
  Long story short, this is an assignment where we have to user RMI in an inverse way, the server commands the clients. Clients register themselves to the server's list and that's where they're added to the IClient list.</p>
  
  <pre><code>    package serviceImplementation;
  
  import commandService.ICommand;
  import commandServiceImplementation.CommandResult;
  import java.rmi.RemoteException;
  import java.rmi.server.UnicastRemoteObject;
  import java.util.ArrayList;
  import service.IClient;
  import service.IServer;
  
  
  public class ServerService extends UnicastRemoteObject implements IServer {
  
      private ArrayList&lt;IClient&gt; clients;
  
      public ServerService() throws RemoteException {
          clients = new ArrayList&lt;&gt;();
      }
  
      @Override
      public boolean register(IClient client) throws RemoteException {
          if(!clients.contains(client)) {
              clients.add(client);
              return true;
          }
          return false;
      }
  
      @Override
      public boolean unRegister(IClient client) throws RemoteException {
          if(clients.contains(client)) {
              clients.remove(client);
              return true;
          }
          return false;
      }
  
      @Override
      public String ping() throws RemoteException {
          long arrival = System.currentTimeMillis();
          System.out.println("Got pinged at [" + arrival + "]");
          return ("server ponged [" + arrival + "]");
      }
  
      @Override
      public CommandResult sendCommand(ICommand command, IClient targetClient) throws RemoteException {
          if(clients.contains(targetClient)) {
              return clients.get(clients.indexOf(targetClient)).executeCommand(command);
          }
          return null;
      }
  
      @Override
      public ArrayList&lt;IClient&gt; getClients() {
          return clients;
      }
  }
  </code></pre>