if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION) {
if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION) { tree.getSelectionModel().clearSelection();
   void selectPath(JTree tree, TreePath path)   {      if (path != null)      {        if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)         {            tree.addSelectionPath(path);            tree.setLeadSelectionPath(path);         }        else if (tree.getSelectionModel().getSelectionMode() == TreeSelectionModel.CONTIGUOUS_TREE_SELECTION)         {            // TODO         }         else         {            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);              tree.getSelectionModel().clearSelection();            tree.addSelectionPath(path);            tree.setLeadSelectionPath(path);         }      }   }