You’ll want to use the ‘setSelectionRows()’ method of the underlying tree component. Here is a little code snippet that I set on a button to select a couple items on a default Vision Tree View component.
from javax.swing.tree import TreeSelectionModel
# get the underlying tree component
tree_component = event.source.parent.getComponent('Tree View').getComponent(0).getComponent(0)
#set our selection model to allow discontiguous selection (e.g., select rows 1 and 3 but not 2)
tree_component.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION)
# the rows we want to select
selected_rows = [2,4]
# now apply the selection to the component
tree_component.setSelectionRows(selected_rows)
You’ll just need to work your selection logic into populating a list like ‘selection_rows’. Hope this helps!