Hi,
When a user selects a leaf, I want to display an icon(number picture) displaying the order in which this leaf is selected. i.e, if node has three leaves, if I click on the first, second and third, I want to display 1,2,3 with the node text. It the user deselects second node, I should automatically renumber the other selected nodes 1 and 2.
I can use the TreeCellRenderer and set the icone for the selected leaf, but, at the same time how do I refresh the icons on the other leafs ?
public Component getTreeCellRendererComponent( JTree tr, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean focus) { super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, focus); /*if (sel) { this.setFont(getFont().deriveFont(Font.BOLD + Font.ITALIC)); } else { this.setFont(getFont().deriveFont(Font.PLAIN)); } */ if ((value != null) && (value instanceof DefaultMutableTreeNode)) { String sSpecial = ((NBTreeNode) value).sSpecial; boolean bSelected = ((NBTreeNode) value).bSelected; if(sSpecial != null) { if (Integer.parseInt(sSpecial) >= 0 && bSelected == true) this.setIcon(Icons[Integer.parseInt(sSpecial)]); else this.setIcon(null); } } return this; }
Any help is greatly appreciated.
Thank you