Ken
Ken

Reputation: 144

GWT add tooltip to Tab

I am using GWT.

I have a TabPanel which has a TabBar with Tabs in it. My issue is that there is no way that i can find to set the Tooltip for the individual Tabs. I get the Tab i want using: getMainTab().getTabBar().getTab(0). There is no operation that allows me to get its header so that i can set its tooltip.
I have looked around but can't find anything useful. I found a setTitle option but thats on the TabBar which is not correct as I need to be able to do it on a specific Tab.

Any suggestions?

Upvotes: 0

Views: 317

Answers (2)

jofeu
jofeu

Reputation: 75

You may want to try this:

// 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);

If you prefer an Image as tab, do it this way:

// 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);

Upvotes: 0

Andrei Volgin
Andrei Volgin

Reputation: 41099

You can pass HTML to a tab header when you add a tab, and this HTML may include title attribute.

Upvotes: 0

Related Questions