我正在尝试使用多个单独的图标(每个Jtree
使用不同的图标)创建一个node
我尝试了多种解决方案,但其中任何一个确实做到了。只需更改“ leaf
,isClosed
等”即可。 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;
}
我希望渲染器将图标应用于指定的节点(与if一起获得),但是它只会将最后选择的图标应用于应已被修改的所有先前节点。其他所有解决方案都以此:/
结尾。谢谢您的时间