Assuming you are using TabPanel
and you haven't provided a custom Widget
for the TabBar
, you could do this:
tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
@Override
public void onSelection(SelectionEvent<Integer> event) {
String tabHtml = tabPanel.getTabBar().getTabHTML(event.getSelectedItem());
}
});
Of course, you will get the underlying HTML of the tab, that generally is a <div>tab text</div>
. The text you put in the add()
methods are wrapped in either a Label
, or an HTML
widget, whether you have chosen to display the tab text as HTML.
Of course this is not handy, generally you need to store somewhere the tab text (in a TabPanel
extension I'd guess, or a model) at insertion time (overriding the add(...)
s) and retrieve it when needed (by adding a simple getter for them).