title: Listener in Table with alert dialog
body: <p>I have 2 table and I want to populate the second table based on what row is selected in the first table. Before populating data in the 2nd table I want an alert dialog where if <code>Yes</code> is pressed new row will be selected in the first table and data will be populated but If<code>No</code> is pressed old row will be kept selected in the first table. how can I do that? I tried like below but stuck in the 2nd portion.</p>
  
  <pre><code>table1.getSelectionModel().selectedItemProperty().addListener((obs, oldSelection, newSelection) -&gt; {
          if (newSelection != null) {
  
  
                      Alert alert = new Alert(AlertType.CONFIRMATION, "Unsaved Data Will be Deleted. Continue" + " ?",
                              ButtonType.YES, ButtonType.NO);
                      alert.showAndWait();
                      if (alert.getResult() == ButtonType.YES) {
  
                          //populate table2
  
                      } else if (alert.getResult() == ButtonType.NO) {
                          // Cancel New Selection and keep the old one
                          Platform.runLater(new Runnable() {
                              @Override
                              public void run() {
  
                              //stuck here
  
                              // how to keep old one selected instead new
                           //table1.getSelectionModel().select(oldSelection); //falls in a infinte loop
                              //return;                       
                              }
                          });
  
                      }
  
                  }
  
  
      });
  </code></pre>