Search code examples
javaswingjtreeexpand

Hide/change collapse [-] and expand [ ] button on JTree


Is there a way to hide the collapse [-] and expand [+] button on a java file JTree?

If it's not possible, is there a way to change it to a different icon?


Solution

  • Yes to both: You can specify an empty Icon, as shown here. You can substitute your own implementation, as shown here. These are the relevant UIManager keys:

    UIManager.put("Tree.collapsedIcon", empty);
    UIManager.put("Tree.expandedIcon", empty);