Im trying to create a Jtree using multiple individual icons (different icons for each node)
i have tried multiple solutions, but any of them really did the job. a lot just changes the "leaf, isClosed, etc." options
ImageIcon pointer;
(INSIDE public Component getTreeCellRendererComponent(..){
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
int nodeLevel = node.getLevel();
switch(nodeLevel){
case 0: { pointer = new ImageIcon(///PATH///)
setIcon(pointer);
break;
case 1: { if(here i check some condition to get an specific amount of nodes){
pointer = new ImageIcon(///PATH2///); // this is a dynamic path. changes with a variable
setIcon(pointer);
}
else{
if(now i check for a specific node){
pointer = new ImageIcon(///PATH3///); // this is a dynamic path. changes with a variable
}
//there are more if's here, but the same situation applies
break;
}
I expect the renderer to apply the icon to the specified node (that i got with the if's), but it just applies the last icon selected to ALL the previous nodes that should have already been modified. every other solution ends like this :/. Thanks for your time