1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public class MyTreeCellRenderer extends DefaultTreeCellRenderer
{
private static final long serialVersionUID = 1L;
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)
{
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof DefaultMutableTreeNode)
{
value = ((DefaultMutableTreeNode) value).getUserObject();
}
if (value instanceof DTOObjectwithAttributes)
{
DTOObjectwithAttributes obj = (DTOObjectwithAttributes) value;
if (obj.isFolder){
this.setIcon(new ImageIcon("/EqGenerator/image/folder16.png"));
this.setText(obj.Attributs);
}else if (obj.isXor){
this.setIcon(new ImageIcon("/EqGenerator/image/xorGate16.png"));
this.setText(obj.Attributs);
}
}
return this;
}
} |
Partager