css - 删除 GWT 树的根项旁边的 +(加号)

标签 css gwt

我想知道是否有人知道是否可以删除出现在 GWT 树中根项旁边的“+”号?我没有看到处理它的 CSS 规则。可以用 GIF 代替 + 号吗?

(出于说明目的改编自以下 GWT 手册的代码)

TreeItem root = new TreeItem("root");//希望删除此项旁边的 + 号

  root.addItem("item0");
  root.addItem("item1");
  root.addItem("item2");
  root.setState(true, true);
  // 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);

最佳答案

CSS 样式根本不适用于此。相反,它需要为树使用不同的构造函数。如果将 spacer.png 设置为 1x1 透明 PNG,它将删除 + 号。这是我使用的完整代码。

正确的做法是:

public interface MyResources extends ClientBundle {
      public static final MyResources INSTANCE =  GWT.create(MyResources.class);

      @Source("spacer.png")
      public ImageResource leaf();


    }


public class TreeImagesExample implements Tree.Resources
{


    @Override
    public ImageResource treeClosed() {
        // TODO Auto-generated method stub
        return MyResources.INSTANCE.leaf();
    }

    @Override
    public ImageResource treeLeaf() {
        // TODO Auto-generated method stub
        return MyResources.INSTANCE.leaf();
    }

    @Override
    public ImageResource treeOpen() {
        // TODO Auto-generated method stub
        return MyResources.INSTANCE.leaf();
    }

} 

Main Function:
     TreeImagesExample tx= new TreeImagesExample();
                Tree t = new Tree(tx);
                t.addItem(root);

为了使其正常工作,当然,我们还需要一个 SelectionHandler,以便我们可以在树项上注册树点击,而不是(现在不存在)+ 符号。

关于css - 删除 GWT 树的根项旁边的 +(加号),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3543666/

相关文章:

html - 如何在 Google Chrome 上修复 1px 边距?

javascript - 当用户上下滚动时移动页面上的元素

java - 根据内存使用情况分析 Eclipse 本身

GWT 从文本字段注册按键事件

html - 使用 flexbox 时如何使图像大小为 'liquid'

javascript - 剪切表格中的文字

html - 使用 Css 显示特定条件下的文本

javascript - 在光标位置插入文本在空行上失败

OSX 上的 GWT,我需要了解什么?

java - 任意精度数字和 Javascript,Google Web Toolkit