GWT 树项目:如何将图像添加到树项目?
我正在使用 gwt 2.3 版本。我在我的应用程序中使用 gwt 树。 这是我的代码:
public void onModuleLoad() {
// Create a tree with a few items in it.
TreeItem root = new TreeItem("root");
root.addItem("item0");
root.addItem("item1");
root.addItem("item2");
// Add a CheckBox to the tree
TreeItem item = new TreeItem(new CheckBox("item3"));
root.addItem(item);
Tree t = new Tree();
t.addItem(root);
// Add it to the root panel.
RootPanel.get().add(t);
}
有一个带有复选框的项目。我想将图像添加到该树项目。但是我无法执行此操作,因为我已经添加了一个小部件复选框。是否有其他方法将图像添加到树项目带复选框??
I am using gwt 2.3 version.I am using gwt tree in my application.
Here is my code:
public void onModuleLoad() {
// Create a tree with a few items in it.
TreeItem root = new TreeItem("root");
root.addItem("item0");
root.addItem("item1");
root.addItem("item2");
// Add a CheckBox to the tree
TreeItem item = new TreeItem(new CheckBox("item3"));
root.addItem(item);
Tree t = new Tree();
t.addItem(root);
// Add it to the root panel.
RootPanel.get().add(t);
}
There is a item with check box.I want add image to this tree item.But I am not able to do this as I already added one widget check box.Is there any other way add image to tree item with check box??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TreeItem 有一个 TreeItem(Widget w) 构造函数。
你可以在里面放任何你想要的东西。因此,编写一个小部件,在 div 中包含彼此相邻的图像和文本,树将正确呈现它。
您已经在示例代码中使用了它。因此,只需再编写一个小部件,将 CheckBox 与 FlowPanel 或 HorizontalPanel 中的图像结合起来即可。任何你想要的。
TreeItem has a TreeItem(Widget w) constructor.
You can put anything you want in there. So write a small widget that has an image and text next to each other in a div and the Tree will render it correctly.
You are already using it in your example code. So just write one more widget that combines the CheckBox with an image in a FlowPanel or HorizontalPanel. Whatever you want.
这也是让我头疼了一段时间的事情。基本上我找到了两个选项:
http://www.smartclient.com/smartgwt/showcase/#tree_databinding_local
http://google -web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/TreeImages.html
如果你问我,SmartGWT 有点苛刻和僵化,你可能不会事实上,它不像 GWT 那样让您进入低级别,但它确实有一组很好的可定制树小部件。另一方面,TreeImage 仍然允许您使用纯 GWT(我认为总体上更好),但它不允许您像 Smart GWT 那样自定义树
This is something that made me whack my head for a while also. Basically I found 2 options:
http://www.smartclient.com/smartgwt/showcase/#tree_databinding_local
http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/TreeImages.html
If you ask me, SmartGWT is somewhat demanding and rigid, and you might not like the fact that it doesn't let you go to the low leves like GWT does but it does have a nice set of customizable tree widgets. TreeImage on the other hand lets you still work with pure GWT (which I think is better overall), but it doesn't let you customize the tree as much as Smart GWT does