Class TabPanel
A panel that represents a tabbed set of pages, each of which contains another
widget. Its child widgets are shown as the user selects the various tabs
associated with them. The tabs can contain arbitrary HTML.

Note that this widget is not a panel per se, but rather a
Composite that aggregates a
TabBar and a
DeckPanel. It does, however, implement
HasWidgets.
CSS Style Rules
- .gwt-TabPanel { the tab panel itself }
- .gwt-TabPanel .Bottom { the bottom section of the tab panel (the deck
containing the widget) }
Example
public class TabPanelExample implements EntryPoint {
public void onModuleLoad() {
// Create a tab panel with three tabs, each of which displays a different
// piece of text.
TabPanel tp = new TabPanel();
tp.add(new HTML("Foo"), "foo");
tp.add(new HTML("Bar"), "bar");
tp.add(new HTML("Baz"), "baz");
// Show the 'bar' tab initially.
tp.selectTab(1);
// Add it to the root panel.
RootPanel.get().add(tp);
}
}
Constructors
Methods
add(Widget, String) | Adds a widget to the tab panel. |
add(Widget, String, boolean) | Adds a widget to the tab panel. |
addTabListener(TabListener) | Adds a listener interface to receive click events. |
getDeckPanel() | Gets the deck panel within this tab panel. |
getTabBar() | Gets the tab bar within this tab panel |
getWidget(int) | |
getWidgetCount() | Gets the number of widgets in this tab panel. |
getWidgetIndex(Widget) | |
insert(Widget, String, boolean, int) | Inserts a widget into the tab panel. |
insert(Widget, String, int) | Inserts a widget into the tab panel. |
iterator() | |
onBeforeTabSelected(SourcesTabEvents, int) | Fired just before a tab is selected. |
onTabSelected(SourcesTabEvents, int) | Fired when a tab is selected |
remove(Widget) | Removes the given widget, and its associated tab. |
removeTabListener(TabListener) | Removes a previously added listener interface. |
selectTab(int) | Programmatically selects the specified tab. |
Constructor Detail
TabPanel
public TabPanel()
Creates an empty tab panel.
Method Detail
add
Adds a widget to the tab panel.
Parameters
- w
- the widget to be added
- tabText
- the text to be shown on its tab
add
Adds a widget to the tab panel.
Parameters
- w
- the widget to be added
- tabText
- the text to be shown on its tab
- asHTML
-
true
to treat the specified text as HTML
addTabListener
Adds a listener interface to receive click events.
Parameters
- listener
- the listener interface to add
getDeckPanel
Gets the deck panel within this tab panel.
Return Value
the deck panel
getTabBar
Gets the tab bar within this tab panel
Return Value
the tab bar
getWidget
public
Widget getWidget(
int index)
Parameters
- index
-
getWidgetCount
public int getWidgetCount()
Gets the number of widgets in this tab panel.
Return Value
the widget count
getWidgetIndex
public int
getWidgetIndex(
Widget child)
Parameters
- child
-
insert
public void
insert(
Widget widget, String tabText, boolean asHTML, int beforeIndex)
Inserts a widget into the tab panel.
Parameters
- widget
- the widget to be inserted
- tabText
- the text to be shown on its tab
- asHTML
-
true
to treat the specified text as HTML
- beforeIndex
- the index before which it will be inserted
insert
public void
insert(
Widget widget, String tabText, int beforeIndex)
Inserts a widget into the tab panel.
Parameters
- widget
- the widget to be inserted
- tabText
- the text to be shown on its tab
- beforeIndex
- the index before which it will be inserted
iterator
See Also
HasWidgets.iterator()
onBeforeTabSelected
Fired just before a tab is selected.
Parameters
- sender
- the TabBar or TabPanel whose tab was
selected.
- tabIndex
- the index of the tab about to be selected
Return Value
false
to disallow the selection. If any listener
returns false, then the selection will be disallowed.
onTabSelected
Fired when a tab is selected
Parameters
- sender
- the TabBar or TabPanel whose tab was selected
- tabIndex
- the index of the tab that was selected
remove
public void
remove(
Widget widget)
Removes the given widget, and its associated tab.
Parameters
- widget
- the widget to be removed
removeTabListener
Removes a previously added listener interface.
Parameters
- listener
- the listener interface to remove
selectTab
public void selectTab(int index)
Programmatically selects the specified tab.
Parameters
- index
- the index of the tab to be selected