Tree filtering

Nuiton-widget provide basic model based tree filtering.


Only two classes are provided:

  • TreeFilter : Interface for tree filter implementation
  • TreeFilterModel : Filtered tree model

The TreeFilter currently has only one method include which must return true only if parameter node must be displayed.


Define your filtered tree:

public class Test {

  protected FilterTreeModel filterModel;


  protected void buildUI() {

    TreeModel realModel = ...
    filterModel = new FilterTreeModel(realModel);

    JTree tree = new JTree(filterModel);


Then apply filtering (when filter need to be updated):

protected void updateFilter(String filterString) {
      TreeFilter myTreeFilter = new MyTreeFilter(filterString);