## com.google.gwt.user.client.ui
Class TabPanel

    java.lang.Object
      com.google.gwt.user.client.ui.UIObject
          com.google.gwt.user.client.ui.Widget
              com.google.gwt.user.client.ui.Composite
                  com.google.gwt.user.client.ui.TabPanel

All Implemented Interfaces:
  HasBeforeSelectionHandlers<java.lang.Integer>, HasSelectionHandlers<java.lang.Integer>, HasHandlers, EventListener, HasAnimation, HasWidgets, IndexedPanel, SourcesTabEvents, TabListener, java.lang.Iterable<Widget>

Direct Known Subclasses:
  DecoratedTabPanel

    public class TabPanel

extends Composite
implements TabListener, SourcesTabEvents, HasWidgets, HasAnimation, IndexedPanel, HasBeforeSelectionHandlers<java.lang.Integer>, HasSelectionHandlers<java.lang.Integer>

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-TabPanelBottom { 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);
>       }
>     }

Nested Class Summary

Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
`UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled`

Field Summary

Fields inherited from class com.google.gwt.user.client.ui.UIObject
`DEBUG_ID_PREFIX`

Constructor Summary
`TabPanel()` Creates an empty tab panel.

Method Summary
`void` | `add(Widget w)` Adds a child widget.
`void` | `add(Widget w, java.lang.String tabText)` Adds a widget to the tab panel.
`void` | `add(Widget w, java.lang.String tabText, boolean asHTML)` Adds a widget to the tab panel.
`void` | `add(Widget w, Widget tabWidget)` Adds a widget to the tab panel.
`HandlerRegistration` | `addBeforeSelectionHandler(BeforeSelectionHandler<java.lang.Integer> handler)` Adds a `BeforeSelectionEvent` handler.
`HandlerRegistration` | `addSelectionHandler(SelectionHandler<java.lang.Integer> handler)` Adds a `SelectionEvent` handler.
`void` | `addTabListener(TabListener listener)` Deprecated. Use `addBeforeSelectionHandler(com.google.gwt.event.logical.shared.BeforeSelectionHandler<java.lang.Integer>)` and `addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<java.lang.Integer>)` instead
`void` | `clear()` Removes all child widgets.
`protected SimplePanel` | `createTabTextWrapper()` Create a `SimplePanel` that will wrap the contents in a tab.
`DeckPanel` | `getDeckPanel()` Gets the deck panel within this tab panel.
`TabBar` | `getTabBar()` Gets the tab bar within this tab panel.
`Widget` | `getWidget(int index)` Gets the child widget at the specified index.
`int` | `getWidgetCount()` Gets the number of child widgets in this panel.
`int` | `getWidgetIndex(Widget widget)` Gets the index of the specified child widget.
`void` | `insert(Widget widget, java.lang.String tabText, boolean asHTML, int beforeIndex)` Inserts a widget into the tab panel.
`void` | `insert(Widget widget, java.lang.String tabText, int beforeIndex)` Inserts a widget into the tab panel.
`void` | `insert(Widget widget, Widget tabWidget, int beforeIndex)` Inserts a widget into the tab panel.
`boolean` | `isAnimationEnabled()`
`java.util.Iterator<Widget>` | `iterator()` Gets an iterator for the contained widgets.
`boolean` | `onBeforeTabSelected(SourcesTabEvents sender, int tabIndex)` Deprecated. Use `BeforeSelectionHandler.onBeforeSelection(com.google.gwt.event.logical.shared.BeforeSelectionEvent)` instead
`protected void` | `onEnsureDebugId(java.lang.String baseID)` Affected Elements: -bar = The tab bar. -bar-tab# = The element containing the content of the tab itself. -bar-tab-wrapper# = The cell containing the tab at the index. -bottom = The panel beneath the tab bar.
`void` | `onTabSelected(SourcesTabEvents sender, int tabIndex)` Deprecated. Use `SelectionHandler.onSelection(com.google.gwt.event.logical.shared.SelectionEvent)` instead
`boolean` | `remove(int index)` Removes the widget at the specified index.
`boolean` | `remove(Widget widget)` Removes the given widget, and its associated tab.
`void` | `removeTabListener(TabListener listener)` Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by and add*Handler method instead
`void` | `selectTab(int index)` Programmatically selects the specified tab.
`void` | `setAnimationEnabled(boolean enable)` Enable or disable animations.

Methods inherited from class com.google.gwt.user.client.ui.Composite
`getWidget, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, sinkEvents`

Methods inherited from class com.google.gwt.user.client.ui.UIObject

`addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Constructor Detail

### TabPanel

    public TabPanel()

  Creates an empty tab panel.

Method Detail

### add

    public void add(Widget w)

  Description copied from interface: `HasWidgets`
  Adds a child widget.

  Specified by:
    `add` in interface `HasWidgets`
  Parameters:
    `w` - the widget to be added

### add

    public void add(Widget w,
                    java.lang.String tabText)

  Adds a widget to the tab panel. If the Widget is already attached to the TabPanel, it will be moved to the right-most index.

  Parameters:
    `w` - the widget to be added
    `tabText` - the text to be shown on its tab

### add

    public void add(Widget w,
                    java.lang.String tabText,
                    boolean asHTML)

  Adds a widget to the tab panel. If the Widget is already attached to the TabPanel, it will be moved to the right-most index.

  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

### add

    public void add(Widget w,
                    Widget tabWidget)

  Adds a widget to the tab panel. If the Widget is already attached to the TabPanel, it will be moved to the right-most index.

  Parameters:
    `w` - the widget to be added
    `tabWidget` - the widget to be shown in the tab

### addBeforeSelectionHandler

    public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<java.lang.Integer> handler)

  Description copied from interface: `HasBeforeSelectionHandlers`
  Adds a `BeforeSelectionEvent` handler.

  Specified by:
    `addBeforeSelectionHandler` in interface `HasBeforeSelectionHandlers<java.lang.Integer>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addSelectionHandler

    public HandlerRegistration addSelectionHandler(SelectionHandler<java.lang.Integer> handler)

  Description copied from interface: `HasSelectionHandlers`
  Adds a `SelectionEvent` handler.

  Specified by:
    `addSelectionHandler` in interface `HasSelectionHandlers<java.lang.Integer>`
  Parameters:
    `handler` - the handler
  Returns:
    the registration for the event

### addTabListener

    @Deprecated
    public void addTabListener(TabListener listener)

  Deprecated. Use `addBeforeSelectionHandler(com.google.gwt.event.logical.shared.BeforeSelectionHandler<java.lang.Integer>)` and `addSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<java.lang.Integer>)` instead

  Description copied from interface: `SourcesTabEvents`
  Adds a listener interface to receive click events.

  Specified by:
    `addTabListener` in interface `SourcesTabEvents`
  Parameters:
    `listener` - the listener interface to add

### clear

    public void clear()

  Description copied from interface: `HasWidgets`
  Removes all child widgets.

  Specified by:
    `clear` in interface `HasWidgets`

### getDeckPanel

    public DeckPanel getDeckPanel()

  Gets the deck panel within this tab panel. Adding or removing Widgets from the DeckPanel is not supported and will throw UnsupportedOperationExceptions.

  Returns:
    the deck panel

### getTabBar

    public TabBar getTabBar()

  Gets the tab bar within this tab panel. Adding or removing tabs from from the TabBar is not supported and will throw UnsupportedOperationExceptions.

  Returns:
    the tab bar

### getWidget

    public Widget getWidget(int index)

  Description copied from interface: `IndexedPanel`
  Gets the child widget at the specified index.

  Specified by:
    `getWidget` in interface `IndexedPanel`
  Parameters:
    `index` - the child widget's index
  Returns:
    the child widget

### getWidgetCount

    public int getWidgetCount()

  Description copied from interface: `IndexedPanel`
  Gets the number of child widgets in this panel.

  Specified by:
    `getWidgetCount` in interface `IndexedPanel`
  Returns:
    the number of children

### getWidgetIndex

    public int getWidgetIndex(Widget widget)

  Description copied from interface: `IndexedPanel`
  Gets the index of the specified child widget.

  Specified by:
    `getWidgetIndex` in interface `IndexedPanel`
  Parameters:
    `widget` - the widget to be found
  Returns:
    the widget's index, or `-1` if it is not a child of this panel

### insert

    public void insert(Widget widget,
                       java.lang.String tabText,
                       boolean asHTML,
                       int beforeIndex)

  Inserts a widget into the tab panel. If the Widget is already attached to the TabPanel, it will be moved to the requested index.

  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,
                       Widget tabWidget,
                       int beforeIndex)

  Inserts a widget into the tab panel. If the Widget is already attached to the TabPanel, it will be moved to the requested index.

  Parameters:
    `widget` - the widget to be inserted.
    `tabWidget` - the widget to be shown on its tab.
    `beforeIndex` - the index before which it will be inserted.

### insert

    public void insert(Widget widget,
                       java.lang.String tabText,
                       int beforeIndex)

  Inserts a widget into the tab panel. If the Widget is already attached to the TabPanel, it will be moved to the requested index.

  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

### isAnimationEnabled

    public boolean isAnimationEnabled()

  Specified by:
    `isAnimationEnabled` in interface `HasAnimation`
  Returns:
    true if animations are enabled, false if not

### iterator

    public java.util.Iterator<Widget> iterator()

  Description copied from interface: `HasWidgets`
  Gets an iterator for the contained widgets. This iterator is required to implement `Iterator.remove()`.

  Specified by:
    `iterator` in interface `HasWidgets`
  Specified by:
    `iterator` in interface `java.lang.Iterable<Widget>`

### onBeforeTabSelected

    @Deprecated
    public boolean onBeforeTabSelected(SourcesTabEvents sender,
                                                  int tabIndex)

  Deprecated. Use `BeforeSelectionHandler.onBeforeSelection(com.google.gwt.event.logical.shared.BeforeSelectionEvent)` instead

  Description copied from interface: `TabListener`
  Fired just before a tab is selected.

  Specified by:
    `onBeforeTabSelected` in interface `TabListener`
  Parameters:
    `sender` - the `TabBar` or `TabPanel` whose tab was selected.
    `tabIndex` - the index of the tab about to be selected
  Returns:
    `false` to disallow the selection. If any listener returns false, then the selection will be disallowed.

### onTabSelected

    @Deprecated
    public void onTabSelected(SourcesTabEvents sender,
                                         int tabIndex)

  Deprecated. Use `SelectionHandler.onSelection(com.google.gwt.event.logical.shared.SelectionEvent)` instead

  Description copied from interface: `TabListener`
  Fired when a tab is selected.

  Specified by:
    `onTabSelected` in interface `TabListener`
  Parameters:
    `sender` - the `TabBar` or `TabPanel` whose tab was selected
    `tabIndex` - the index of the tab that was selected

### remove

    public boolean remove(int index)

  Description copied from interface: `IndexedPanel`
  Removes the widget at the specified index.

  Specified by:
    `remove` in interface `IndexedPanel`
  Parameters:
    `index` - the index of the widget to be removed
  Returns:
    `false` if the widget is not present

### remove

    public boolean remove(Widget widget)

  Removes the given widget, and its associated tab.

  Specified by:
    `remove` in interface `HasWidgets`
  Parameters:
    `widget` - the widget to be removed
  Returns:
    `true` if the widget was present

### removeTabListener

    @Deprecated
    public void removeTabListener(TabListener listener)

  Deprecated. Use the `HandlerRegistration.removeHandler()` method on the object returned by and add*Handler method instead

  Description copied from interface: `SourcesTabEvents`
  Removes a previously added listener interface.

  Specified by:
    `removeTabListener` in interface `SourcesTabEvents`
  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

### setAnimationEnabled

    public void setAnimationEnabled(boolean enable)

  Description copied from interface: `HasAnimation`
  Enable or disable animations.

  Specified by:
    `setAnimationEnabled` in interface `HasAnimation`
  Parameters:
    `enable` - true to enable, false to disable

### createTabTextWrapper

    protected SimplePanel createTabTextWrapper()

  Create a `SimplePanel` that will wrap the contents in a tab. Subclasses can use this method to wrap tabs in decorator panels.

  Returns:
    a `SimplePanel` to wrap the tab contents, or null to leave tabs unwrapped

### onEnsureDebugId

    protected void onEnsureDebugId(java.lang.String baseID)

  Affected Elements:
  - -bar = The tab bar.
  - -bar-tab# = The element containing the content of the tab itself.
  - -bar-tab-wrapper# = The cell containing the tab at the index.
  - -bottom = The panel beneath the tab bar.

  Overrides:
    `onEnsureDebugId` in class `UIObject`
  Parameters:
    `baseID` - the base ID used by the main element
  See Also:
    `UIObject.onEnsureDebugId(String)`