title: JavaFX TableView filter using TextField
body: <p>I want to code a method where I pass a textfield (filterField), data from a tableview (data) and tableview (table) in order to filter all the table data, checking each time a key is released in the textfield, if the string typed is contained in any cell of the table.</p>
  
  <p>This method is to be generic and used for different type of tables with different column headers.</p>
  
  <p>To do so I´m using the following code:</p>
  
  <pre><code>public void addTextFilter(ObservableList&lt;List&lt;Object&gt;&gt; allData, 
                             JFXTextField filterField, TableView&lt;List&lt;Object&gt;&gt; table) {
  
      FilteredList&lt;List&lt;Object&gt;&gt; filteredData  = new FilteredList&lt;&gt;(allData, p -&gt; true);
      filterField.setOnKeyReleased(e -&gt; 
      {
           filteredData.setPredicate(p  -&gt; 
           {
               if (filterField.getText() == null || filterField.getText().isEmpty()){
                   return true;
               }else {
                   return p.contains(filterField.getText()); 
               }
           });
  
  
      });
  
      SortedList&lt;List&lt;Object&gt;&gt; sortedData = new SortedList&lt;&gt;(filteredData);
      sortedData.comparatorProperty().bind(table.comparatorProperty());
      table.setItems(sortedData);
  }
  </code></pre>
  
  <p>This code only returns the values when the string in the textfield matches exactly the value of any cell in the table.</p>
  
  <p>I would need it to return any cell of the table that contains the string typed in it while typing, even if the cell contains more characters. Something similar to this: <a href="https://code.makery.ch/blog/javafx-8-tableview-sorting-filtering/" rel="nofollow noreferrer">JavaFX 8 TableView Sorting and Filtering</a></p>
  
  <p>I would also need it to return values not depending on lowercase or uppercase values.</p>