How do I make my Jtree look like something below, with plus and minus icons that allows expansion and collapse?
Currently, the default JTree only expands and collapses when you double click. I want to override this double click for another functionality and let the user expand/collapse the tree by only clicking on the minus and plus icons such as below.
Best Answer
You have to change the
Tree.collapsedIcon
andTree.expandedIcon
properties of the L&F and supply your own icons:Here is the icon I use, it's simple square with a +/- inside: