title: Mimicking CTRL+Click Multiple Selection in ListView using Javafx
body: <p>I'm trying to find different ways of selecting multiple items in a ListView. The GUI will be running on a touch screen monitor, So I won't be able to CTRL+Click. From researching through various past posts, I have been able to implement Multiple Selection via keeping all the selected items in an Array and then looping through it to get the final selections. The only problem I have with my code is that compared to a CTRL +click , the selection is done smoothly, where as my code leads to a type flickering every time a new item is selected. So basically the listView clears all the selections and then selects the correct ones. Is there a way to make this transition go smoothly? Would it be easier to mimic a touch to have CTRL+click effect?</p>
  
  <pre><code>selectedList = new int[totalTypes];//total number of item properties
  
  for(int x=0; x&lt;selectedList.length;x++){//0 = not selected, 1 = selected
      selectedList[x]=0;
  }
  testView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
  
      testView.setOnMouseClicked(new EventHandler&lt;Event&gt;(){
          @Override
          public void handle(Event event){
                  if(selectedList[testView.getSelectionModel().getSelectedIndex()]==0){
                      selectedList[testView.getSelectionModel().getSelectedIndex()]=1;
                  }
                  else{
                      selectedList[testView.getSelectionModel().getSelectedIndex()]=0;
                  }
  
                  for(int x=0; x&lt;selectedList.length;x++){
                      if(selectedList[x]==1){
                          testView.getSelectionModel().select(x); 
                      }
                      else{
                          testView.getSelectionModel().clearSelection(x);;
                      }
                  }
  
  
          }
  
      });
  </code></pre>