关于 SWT Tree 的问题??帮帮我 啊。。。

zhang4138151 2008-03-16 01:18:32
final Composite topComposite=new Composite(shell, SWT.NONE);
RowLayout topComposite_layout=new RowLayout();
topComposite_layout.type=SWT.VERTICAL;
topComposite.setLayout(topComposite_layout);


Tree tree = new Tree(topComposite, SWT.FULL_SELECTION );
TreeItem root = new TreeItem(tree, SWT.NULL);

root.setText("root");
for (int i = 0; i < 10; i++) {
TreeItem item = new TreeItem(root, SWT.NULL);
item.setText("Item"+i);
Image find_image_xiao=new Image(item.getDisplay(),
"E:\\java\\myeclipse'workspace\\XXX_SW\\" +
"image\\test_image\\frind5hao.png");
item.setImage(find_image_xiao);
}
能成功运行的,但是tree时缩在一个很小的方块里边,只能看到一个item....

自动添加了滚动条了。。。。。

root.setSize(...);也没用啊。。。

帮帮我啊

谢谢!~~
...全文
88 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeff_jian 2008-03-16
  • 打赏
  • 举报
回复
这样,上一个写多了.
汗ing...
		final Composite topComposite = new Composite(shell, SWT.NONE);
// RowLayout topComposite_layout = new RowLayout();
// topComposite_layout.type = SWT.VERTICAL;
// topComposite.setLayout(topComposite_layout);
topComposite.setLayout(new FillLayout());

Tree tree = new Tree(topComposite, SWT.FULL_SELECTION);
TreeItem root = new TreeItem(tree, SWT.NULL);
root.setText("root");
for (int i = 0; i < 10; i++) {
TreeItem item = new TreeItem(root, SWT.NULL);
item.setText("Item" + i);
Image find_image_xiao = new Image(item.getDisplay(),
"E:\\java\\myeclipse'workspace\\XXX_SW\\"
+ "image\\test_image\\frind5hao.png");
item.setImage(find_image_xiao);
}
jeff_jian 2008-03-16
  • 打赏
  • 举报
回复
这样改:
		shell.setLayout(new FillLayout());
Composite topComposite = new Composite(shell, SWT.NONE);
// RowLayout topComposite_layout = new RowLayout();
// topComposite_layout.type = SWT.VERTICAL;
// topComposite.setLayout(topComposite_layout);
topComposite.setLayout(new FillLayout());

Tree tree = new Tree(topComposite, SWT.FULL_SELECTION);
TreeItem root = new TreeItem(tree, SWT.NULL);
root.setText("root");
for (int i = 0; i < 10; i++) {
TreeItem item = new TreeItem(root, SWT.NULL);
item.setText("Item" + i);
Image find_image_xiao = new Image(item.getDisplay(),
"E:\\java\\myeclipse'workspace\\XXX_SW\\"
+ "image\\test_image\\frind5hao.png");
item.setImage(find_image_xiao);
}

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧