【问题标题】:How to kill a Tab in a Tab Panel如何在选项卡面板中杀死一个选项卡
【发布时间】:2009-10-27 18:25:58
【问题描述】:

我创建了一个选项卡面板,单击按钮可以在其中添加其他选项卡。

我不知道如何删除不是最后添加的选项卡。

我在这里....

TabPanel tp = new TabPanel(); Horizo​​ntalPanel tabPanel = new Horizo​​ntalPanel(); Label textLabel = new Label("Some Filename"); 按钮 killButton = new Button("x");

tabPanel.add(textLabel); tabPanel.add(killButton);

tp.add(new HTML("Some Content"), tabPanel);//正文和标题

killButton.addClickHandler(新 ClickHandler(){ public void onClick(ClickEvent 事件){

  //Decide the Tab index that contains this button
  //Remove this tab based on index

} });//addClickHandler方法结束

当我尝试使用 getWidgetIndex() 方法返回特定选项卡的索引时,我每次都会得到 -1。

如何正确返回选项卡的索引?

请帮忙,我快疯了!!!

:-(

【问题讨论】:

    标签: gwt


    【解决方案1】:

    要删除选项卡,您需要引用作为选项卡内容添加的小部件,或者需要要删除的选项卡的选项卡索引。你上面的例子的一部分就像

    最终 TabPanel tp = new TabPanel(); final HTML someContent1 = new HTML("Page A"); ... public void onClick(ClickEvent 事件){ tp.remove(someContent1); // 或者只是删除它自己的选项卡 //tp.getTabBar().removeTab(0); }

    宁张网

    【讨论】:

      【解决方案2】:

      getWidgetIndex 需要内容小部件而不是选项卡小部件作为参数。因此,例如在您的情况下,这将是使用 new HTML("Some Content") 创建的小部件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-10-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多