SWT/JFace 中CheckBoxTreeViewer 子节点部分选中,父节点为半选状态,改用tree+checkox的方式如何实现?
2个回答
2011-04-20
展开全部
显示图片
Tree tree=new Tree(compA[0],SWT.NONE);//创建树
TreeItem item=new TreeItem(tree,SWT.NONE);
item.setText("音乐");
TreeItem child=new TreeItem(item,SWT.NONE);//在此TreeItem上加入图片
TreeItem child1=new TreeItem(child,SWT.NONE);
TreeItem child2=new TreeItem(child,SWT.NONE);
child1.setText("安静");
child2.setText("简单爱");
TreeEditor editor=new TreeEditor(tree);//创建TreeEditor
editor.horizontalAlignment = SWT.LEFT;
editor.minimumWidth = 50;
CLabel lbl = new CLabel(tree, SWT.SHADOW_OUT);//创建控件,显示图片
lbl.setSize(120, 30);
lbl.setBackground(SWTResourceManager.getImage(TestTree.class, "/images/forward.gif"));
editor.setEditor(lbl, child, 0); //为TreeEditor加在child上,child上加入控件lbl,lbl上显示图片
标签器的几个方法中
getImage 返回的是TreeItem之前的图像
getText 返回的是TreeItem的文本
都不能实现这种要求
充满的话 创建一个Canvas 加上addPaintListener事件 重绘Image
final Canvas lbl = new Canvas(tree, SWT.SHADOW_OUT);
lbl.addPaintListener(new PaintListener()
{
public void paintControl(PaintEvent e) {
Image image=SWTResourceManager.getImage(TestTree.class, "/images/forward.gif");
ImageData data=image.getImageData();
ImageData data1=data.scaledTo(lbl.getSize().x, lbl.getSize().y);
Image im=new Image(e.display,data1);
e.gc.drawImage(im,0,0);
im.dispose();
}
});
editor.setEditor(lbl, child, 0);
另外,虚机团上产品团购,超级便宜
Tree tree=new Tree(compA[0],SWT.NONE);//创建树
TreeItem item=new TreeItem(tree,SWT.NONE);
item.setText("音乐");
TreeItem child=new TreeItem(item,SWT.NONE);//在此TreeItem上加入图片
TreeItem child1=new TreeItem(child,SWT.NONE);
TreeItem child2=new TreeItem(child,SWT.NONE);
child1.setText("安静");
child2.setText("简单爱");
TreeEditor editor=new TreeEditor(tree);//创建TreeEditor
editor.horizontalAlignment = SWT.LEFT;
editor.minimumWidth = 50;
CLabel lbl = new CLabel(tree, SWT.SHADOW_OUT);//创建控件,显示图片
lbl.setSize(120, 30);
lbl.setBackground(SWTResourceManager.getImage(TestTree.class, "/images/forward.gif"));
editor.setEditor(lbl, child, 0); //为TreeEditor加在child上,child上加入控件lbl,lbl上显示图片
标签器的几个方法中
getImage 返回的是TreeItem之前的图像
getText 返回的是TreeItem的文本
都不能实现这种要求
充满的话 创建一个Canvas 加上addPaintListener事件 重绘Image
final Canvas lbl = new Canvas(tree, SWT.SHADOW_OUT);
lbl.addPaintListener(new PaintListener()
{
public void paintControl(PaintEvent e) {
Image image=SWTResourceManager.getImage(TestTree.class, "/images/forward.gif");
ImageData data=image.getImageData();
ImageData data1=data.scaledTo(lbl.getSize().x, lbl.getSize().y);
Image im=new Image(e.display,data1);
e.gc.drawImage(im,0,0);
im.dispose();
}
});
editor.setEditor(lbl, child, 0);
另外,虚机团上产品团购,超级便宜
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询