【问题标题】:GWT add tooltip to TabGWT 将工具提示添加到选项卡
【发布时间】:2016-01-15 11:11:44
【问题描述】:

我正在使用 GWT。

我有一个 TabPanel,它有一个 TabBar,里面有标签。我的问题是我找不到为各个选项卡设置工具提示的方法。 我得到了我想要使用的标签:getMainTab().getTabBar().getTab(0)。 没有任何操作可以让我获取它的标题以便我可以设置它的工具提示。
我环顾四周,但找不到任何有用的东西。我找到了一个 setTitle 选项,但那是在 TabBar 上,这是不正确的,因为我需要能够在特定的选项卡上执行此操作。

有什么建议吗?

【问题讨论】:

    标签: gwt tabs tooltip tabbar tabpanel


    【解决方案1】:

    您可以在添加选项卡时将 HTML 传递给选项卡标题,该 HTML 可能包含title 属性。

    【讨论】:

    【解决方案2】:

    你可能想试试这个:

    // Create a tab bar
    tabLayoutPanel = new TabLayoutPanel(100, Unit.PX);
    
    // Create a panel
    FlowPanel tabPanel = new FlowPanel();
    // fill the tab with its contents ...
    
    // Create HTML as tab for the panel
    HTML htmlTab = new HTML("HTML-Tab");
    htmlTab.setTitle("Tooltip for HTML");
    
    // Add panel with its tab to the tabLayoutPanel
    tablayoutPanel.add(tabPanel, htmlTab);
    

    如果您更喜欢将图像作为选项卡,请按以下方式操作:

    // Create an image as tab for the panel 
    Image imageTab = new Image(... your image resoure ...);
    imageTab.setTitle("Tooltip for Image");
    
    // Add panel with its tab to the tabLayoutPanel
    tablayoutPanel.add(tabPanel, imageTab);
    

    【讨论】:

      猜你喜欢
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      • 2012-11-02
      • 2017-06-03
      • 1970-01-01
      • 2015-04-11
      • 2021-12-13
      相关资源
      最近更新 更多