treeViewer中setSelection()的用法
点击次数:165 次 发布日期:2008-09-19 14:13:34 作者:源代码网
|
函数的原型为: 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 的方法 源代码网推荐 源代码网供稿. |
