当前页面: 开发资料首页 → Eclipse 专题 → 菜鸟求问treeViewer中setSelection()的用法
菜鸟求问treeViewer中setSelection()的用法
摘要: 菜鸟求问treeViewer中setSelection()的用法
我想用setSelection()方法在程序中选中树的子节点,但是老报错。
函数的原型为:
protected void setSelection(List items)
而我用来选择的东西--树的子节点没有implements List..请问怎么办???
树子节点的源代码:
public class AttributeCh implements ITreeEntry {
private Long id;
......
public AttributeCh() {
}
public AttributeCh(String name) {
this.name = name;
}
public Long getId() {
return id;
}
.......
public void setParent(Object parent) {
this.parent= parent;
}
public Object getParent() {
return parent;
}
}
public interface ITreeEntry
{
//设置与得到树节点的名称
public String getName();
public void setName(String name);
//设置与得到子节点集合
public void setChildren(ArrayList children);
public ArrayList getChildren();
public void setParent(Object parent);
public Object getParent();
}
有人给我这样的解答
用TreeViewer的setSelection方法,比如我一个Tree代码的选择方法是这样写的,Phone是
树的数据类
private void setTreeSelection(Phone phone) {
TreePath treePath = new TreePath(new Object[] {// 路径构建
phone.getParent(), phone });
TreeSelection sel = new TreeSelection(treePath);
tv.setSelection(sel);
}
但是我的jdk版本是1.42没有TreeSelection 的方法....搞了好久啊 希望大家帮帮忙,谢谢
up
解决...同志就你UP 送你分吧...
HOHO
谢谢啦。。