I need to ask for a little hint about node selection in my JXTreeTable
.
I added some nodes to it and want to select one node as Default by program. My test function for selecting a node looks like this:
public void setSelectionTest()
{
Object dfltObj;
TreeSelectionModel tsm = jttRulesSet.getTreeSelectionModel();
TreeTableModelRules ttm = (TreeTableModelRules)jttRulesSet.getTreeTableModel();
TreePath tp;
dfltObj = ttm.getChild(ttm.getRoot(), 0);
if( (dfltObj != null) )
{
System.out.println("Node to select: " + dfltObj.getClass());
tp = new TreePath(dfltObj);
tsm.setSelectionPath(tp);
jttRulesSet.scrollPathToVisible(tp);
}
My test function for verifiing the effect:
public void getSelectionTest()
{
TreeSelectionModel tsm;
TreePath treeSelPath;
Object dfltNode;
tsm = jttRulesSet.getTreeSelectionModel(); // get treeselectionmodel
treeSelPath = tsm.getSelectionPath(); // get selected path
if(treeSelPath != null)
{
dfltNode = treeSelPath.getLastPathComponent();
System.out.println("Selected node: " + ((RulesSet) dfltNode).getName()); // info bout the selected path
System.out.println("Selected node: " + tsm.getSelectionCount());
}
}
I get Name and number of selected row. So far OK. But the JXTreeTable
shows no selection. The jttRulesSet.expandPath(tp)
line has no effect as well. There must be an undiscovered fact behind...
Can somebody give me any tip to solve this problem?