Customizing Tree.collapsedIcon for a single JTree

前端 未结 3 970
醉酒成梦
醉酒成梦 2020-11-30 15:49

I know that you can change the Tree.collapsedIcon for a all JTrees in an application using Swing using the UImanager. For example:

3条回答
  •  臣服心动
    2020-11-30 16:16

    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);
    }
    

提交回复
热议问题