[英]JFace: Change Color of TreeItem in TreeViewer
我试图在运行时在包含TreeViewer的类中更改特定TreeNodes的BackgroundColor,但是它不起作用:
....
Display display = Display.getCurrent();
for (TreeItem item : treeItems) {
if (item.getParentItem() != null) {
Object parentElement = item.getParentItem().getData();
if(parentElement instanceof Or){
System.out.println(item);
Color color = new Color(display,12, 197, 77);
item.setBackground(color);
item.setForeground(color);
}
}
}
......
我想知道为什么这不起作用,因为TreeItem具有相应的方法。
请注意,我不想为此使用Labelprovider,因为我必须检查节点之间的多个依赖关系以确定正确的Color,因此,Labelprovider不适合使用。
干杯,菲尔
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.