analyseWriter/src/fenetres/MyTreeCellRenderer.java

40 lines
1.1 KiB
Java
Raw Normal View History

package app;
import java.awt.Color;
import java.awt.Component;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
import cXML.node;
public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean sel, boolean exp, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, exp, leaf, row, hasFocus);
// Assuming you have a tree of Strings
node nod = (node) ((DefaultMutableTreeNode) value).getUserObject();
// If the node is a leaf and ends with "xxx"
// if (leaf && nod.endsWith("xxx")) {
// // Paint the node in blue
// setForeground(new Color(13, 57 ,115));
// }
if(nod.getAttributs().get("evaluer")!=null) {
if(nod.getAttributs().get("evaluer").equals("true")) setForeground(new Color(0, 240 ,50));
}
return this;
}
}