Customizing Tree.collapsedIcon for a single JTree

If you make the assumption that TreeUI that you are using is an instance of BasicTreeUI, you can do the following:

TreeUI tui = treeInstance.getUI();
if (tui instanceof BasicTreeUI) {
  ((BasicTreeUI)tui).setCollapsedIcon(myIcon);
}

Leave a Comment