GWT 2.7.0

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

    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.ResizeComposite
                      com.google.gwt.user.client.ui.TabLayoutPanel

All Implemented Interfaces:
  HasAttachHandlers, HasBeforeSelectionHandlers<java.lang.Integer>, HasSelectionHandlers<java.lang.Integer>, HasHandlers, EventListener, AnimatedLayout, HasVisibility, HasWidgets, IndexedPanel, IndexedPanel.ForIsWidget, IsRenderable, IsWidget, ProvidesResize, RequiresResize, java.lang.Iterable<Widget>

    public class TabLayoutPanel

extends ResizeComposite
implements HasWidgets, ProvidesResize, IndexedPanel.ForIsWidget, AnimatedLayout, 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 text, HTML, or widgets.

This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.

### CSS Style Rules

.gwt-TabLayoutPanel
  the panel itself
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabs
  the tab bar element
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTab
  an individual tab
.gwt-TabLayoutPanel .gwt-TabLayoutPanelTabInner
  an element nested in each tab (useful for styling)
.gwt-TabLayoutPanel .gwt-TabLayoutPanelContent
  applied to all child content widgets

### Example

>     public class TabLayoutPanelExample implements EntryPoint {

>       public void onModuleLoad() {
>         // Create a three-item tab panel, with the tab area 1.5em tall.
>         TabLayoutPanel p = new TabLayoutPanel(1.5, Unit.EM);
>         p.add(new HTML("this"), "[this]");
>         p.add(new HTML("that"), "[that]");
>         p.add(new HTML("the other"), "[the other]");

>         // Attach the LayoutPanel to the RootLayoutPanel. The latter will listen for
>         // resize events on the window to ensure that its children are informed of
>         // possible size changes.
>         RootLayoutPanel rp = RootLayoutPanel.get();
>         rp.add(p);
>       }
>     }

### Use in UiBinder Templates

A TabLayoutPanel element in a `UiBinder` template must have a `barHeight` attribute with a double value, and may have a `barUnit` attribute with a `Style.Unit` value. `barUnit` defaults to PX.

The children of a TabLayoutPanel element are laid out in <g:tab> elements. Each tab can have one widget child and one of two types of header elements. A <g:header> element can hold html, or a <g:customHeader> element can hold a widget. (Note that the tags of the header elements are not capitalized. This is meant to signal that the head is not a runtime object, and so cannot have a `ui:field` attribute.)

For example:

     <g:TabLayoutPanel barUnit='EM' barHeight='3'>
      <g:tab>
        <g:header size='7'><b>HTML</b> header</g:header>
        <g:Label>able</g:Label>
      </g:tab>
      <g:tab>
        <g:customHeader size='7'>
          <g:Label>Custom header</g:Label>
        </g:customHeader>
        <g:Label>baker</g:Label>
      </g:tab>
     </g:TabLayoutPanel>

Nested Class Summary

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

Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
`HasWidgets.ForIsWidget`

Field Summary

Fields inherited from class com.google.gwt.user.client.ui.Widget
`eventsToSink`

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

Constructor Summary
`TabLayoutPanel(double barHeight, Style.Unit barUnit)` Creates an empty tab panel.

Method Summary
`void` | `add(IsWidget w)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `add(IsWidget w, IsWidget tab)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `add(IsWidget w, java.lang.String text)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `add(IsWidget w, java.lang.String text, boolean asHtml)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `add(Widget w)` Adds a child widget.
`void` | `add(Widget child, SafeHtml html)` Adds a widget to the panel.
`void` | `add(Widget child, java.lang.String text)` Adds a widget to the panel.
`void` | `add(Widget child, java.lang.String text, boolean asHtml)` Adds a widget to the panel.
`void` | `add(Widget child, Widget tab)` Adds a widget to the panel.
`HandlerRegistration` | `addBeforeSelectionHandler(BeforeSelectionHandler<java.lang.Integer> handler)` Adds a `BeforeSelectionEvent` handler.
`HandlerRegistration` | `addSelectionHandler(SelectionHandler<java.lang.Integer> handler)` Adds a `SelectionEvent` handler.
`void` | `animate(int duration)` Layout children, animating over the specified period of time.
`void` | `animate(int duration, Layout.AnimationCallback callback)` Layout children, animating over the specified period of time.
`void` | `clear()` Removes all child widgets.
`void` | `forceLayout()` Layout children immediately.
`int` | `getAnimationDuration()` Get the duration of the animated transition between tabs.
`int` | `getSelectedIndex()` Gets the index of the currently-selected tab.
`Widget` | `getTabWidget(int index)` Gets the widget in the tab at the given index.
`Widget` | `getTabWidget(IsWidget child)` Convenience overload to allow `IsWidget` to be used directly.
`Widget` | `getTabWidget(Widget child)` Gets the widget in the tab associated with the given child widget.
`Widget` | `getWidget(int index)` Returns the widget at the given index.
`int` | `getWidgetCount()` Returns the number of tabs and widgets.
`int` | `getWidgetIndex(IsWidget child)` Convenience overload to allow `IsWidget` to be used directly.
`int` | `getWidgetIndex(Widget child)` Returns the index of the given child, or -1 if it is not a child.
`void` | `insert(IsWidget child, int beforeIndex)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `insert(IsWidget child, IsWidget tab, int beforeIndex)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `insert(IsWidget child, java.lang.String text, boolean asHtml, int beforeIndex)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `insert(IsWidget child, java.lang.String text, int beforeIndex)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `insert(Widget child, int beforeIndex)` Inserts a widget into the panel.
`void` | `insert(Widget child, SafeHtml html, int beforeIndex)` Inserts a widget into the panel.
`void` | `insert(Widget child, java.lang.String text, boolean asHtml, int beforeIndex)` Inserts a widget into the panel.
`void` | `insert(Widget child, java.lang.String text, int beforeIndex)` Inserts a widget into the panel.
`void` | `insert(Widget child, Widget tab, int beforeIndex)` Inserts a widget into the panel.
`boolean` | `isAnimationVertical()` Check whether or not transitions slide in vertically or horizontally.
`java.util.Iterator<Widget>` | `iterator()` Gets an iterator for the contained widgets.
`boolean` | `remove(int index)` Removes the widget at the specified index.
`boolean` | `remove(Widget w)` Removes a child widget.
`void` | `selectTab(int index)` Programmatically selects the specified tab and fires events.
`void` | `selectTab(int index, boolean fireEvents)` Programmatically selects the specified tab.
`void` | `selectTab(IsWidget child)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `selectTab(IsWidget child, boolean fireEvents)` Convenience overload to allow `IsWidget` to be used directly.
`void` | `selectTab(Widget child)` Programmatically selects the specified tab and fires events.
`void` | `selectTab(Widget child, boolean fireEvents)` Programmatically selects the specified tab.
`void` | `setAnimationDuration(int duration)` Set the duration of the animated transition between tabs.
`void` | `setAnimationVertical(boolean isVertical)` Set whether or not transitions slide in vertically or horizontally.
`void` | `setTabHTML(int index, SafeHtml html)` Sets a tab's HTML contents.
`void` | `setTabHTML(int index, java.lang.String html)` Sets a tab's HTML contents.
`void` | `setTabText(int index, java.lang.String text)` Sets a tab's text contents.

Methods inherited from class com.google.gwt.user.client.ui.ResizeComposite
`initWidget, onResize`

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

Methods inherited from class com.google.gwt.user.client.ui.Widget
`addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents`

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, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString`

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`

Constructor Detail

### TabLayoutPanel

    public TabLayoutPanel(double barHeight,
                          Style.Unit barUnit)

  Creates an empty tab panel.

  Parameters:
    `barHeight` - the size of the tab bar
    `barUnit` - the unit in which the tab bar size is specified

Method Detail

### add

    public void add(IsWidget w)

  Convenience overload to allow `IsWidget` to be used directly.

### add

    public void add(IsWidget w,
                    IsWidget tab)

  Convenience overload to allow `IsWidget` to be used directly.

### add

    public void add(IsWidget w,
                    java.lang.String text)

  Convenience overload to allow `IsWidget` to be used directly.

### add

    public void add(IsWidget w,
                    java.lang.String text,
                    boolean asHtml)

  Convenience overload to allow `IsWidget` to be used directly.

### 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 child,
                    java.lang.String text)

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

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

### add

    public void add(Widget child,
                    SafeHtml html)

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

  Parameters:
    `child` - the widget to be added
    `html` - the html to be shown on its tab

### add

    public void add(Widget child,
                    java.lang.String text,
                    boolean asHtml)

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

  Parameters:
    `child` - the widget to be added
    `text` - the text to be shown on its tab
    `asHtml` - `true` to treat the specified text as HTML

### add

    public void add(Widget child,
                    Widget tab)

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

  Parameters:
    `child` - the widget to be added
    `tab` - the widget to be placed in the associated 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

### animate

    public void animate(int duration)

  Description copied from interface: `AnimatedLayout`
  Layout children, animating over the specified period of time.

  Specified by:
    `animate` in interface `AnimatedLayout`
  Parameters:
    `duration` - the animation duration, in milliseconds

### animate

    public void animate(int duration,
                        Layout.AnimationCallback callback)

  Description copied from interface: `AnimatedLayout`
  Layout children, animating over the specified period of time.

  This method provides a callback that will be informed of animation updates. This can be used to create more complex animation effects.

  Specified by:
    `animate` in interface `AnimatedLayout`
  Parameters:
    `duration` - the animation duration, in milliseconds
    `callback` - the animation callback

### clear

    public void clear()

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

  Specified by:
    `clear` in interface `HasWidgets`

### forceLayout

    public void forceLayout()

  Description copied from interface: `AnimatedLayout`
  Layout children immediately.

  This is not normally necessary, unless you want to update child widgets' positions explicitly to create a starting point for a subsequent call to `AnimatedLayout.animate(int)`.

  Specified by:
    `forceLayout` in interface `AnimatedLayout`
  See Also:
    `AnimatedLayout.animate(int)`, `AnimatedLayout.animate(int, Layout.AnimationCallback)`

### getAnimationDuration

    public int getAnimationDuration()

  Get the duration of the animated transition between tabs.

  Returns:
    the duration in milliseconds

### getSelectedIndex

    public int getSelectedIndex()

  Gets the index of the currently-selected tab.

  Returns:
    the selected index, or `-1` if none is selected.

### getTabWidget

    public Widget getTabWidget(int index)

  Gets the widget in the tab at the given index.

  Parameters:
    `index` - the index of the tab to be retrieved
  Returns:
    the tab's widget

### getTabWidget

    public Widget getTabWidget(IsWidget child)

  Convenience overload to allow `IsWidget` to be used directly.

### getTabWidget

    public Widget getTabWidget(Widget child)

  Gets the widget in the tab associated with the given child widget.

  Parameters:
    `child` - the child whose tab is to be retrieved
  Returns:
    the tab's widget

### getWidget

    public Widget getWidget(int index)

  Returns the widget at the given index.

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

### getWidgetCount

    public int getWidgetCount()

  Returns the number of tabs and widgets.

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

### getWidgetIndex

    public int getWidgetIndex(IsWidget child)

  Convenience overload to allow `IsWidget` to be used directly.

  Specified by:
    `getWidgetIndex` in interface `IndexedPanel.ForIsWidget`

### getWidgetIndex

    public int getWidgetIndex(Widget child)

  Returns the index of the given child, or -1 if it is not a child.

  Specified by:
    `getWidgetIndex` in interface `IndexedPanel`
  Parameters:
    `child` - 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(IsWidget child,
                       int beforeIndex)

  Convenience overload to allow `IsWidget` to be used directly.

### insert

    public void insert(IsWidget child,
                       IsWidget tab,
                       int beforeIndex)

  Convenience overload to allow `IsWidget` to be used directly.

### insert

    public void insert(IsWidget child,
                       java.lang.String text,
                       boolean asHtml,
                       int beforeIndex)

  Convenience overload to allow `IsWidget` to be used directly.

### insert

    public void insert(IsWidget child,
                       java.lang.String text,
                       int beforeIndex)

  Convenience overload to allow `IsWidget` to be used directly.

### insert

    public void insert(Widget child,
                       int beforeIndex)

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

  Parameters:
    `child` - the widget to be added
    `beforeIndex` - the index before which it will be inserted

### insert

    public void insert(Widget child,
                       SafeHtml html,
                       int beforeIndex)

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

  Parameters:
    `child` - the widget to be added
    `html` - the html to be shown on its tab
    `beforeIndex` - the index before which it will be inserted

### insert

    public void insert(Widget child,
                       java.lang.String text,
                       boolean asHtml,
                       int beforeIndex)

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

  Parameters:
    `child` - the widget to be added
    `text` - 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 child,
                       java.lang.String text,
                       int beforeIndex)

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

  Parameters:
    `child` - the widget to be added
    `text` - the text to be shown on its tab
    `beforeIndex` - the index before which it will be inserted

### insert

    public void insert(Widget child,
                       Widget tab,
                       int beforeIndex)

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

  Parameters:
    `child` - the widget to be added
    `tab` - the widget to be placed in the associated tab
    `beforeIndex` - the index before which it will be inserted

### isAnimationVertical

    public boolean isAnimationVertical()

  Check whether or not transitions slide in vertically or horizontally. Defaults to horizontally.

  Returns:
    true for vertical transitions, false for horizontal

### 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>`

### 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 w)

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

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

### selectTab

    public void selectTab(int index)

  Programmatically selects the specified tab and fires events.

  Parameters:
    `index` - the index of the tab to be selected

### selectTab

    public void selectTab(int index,
                          boolean fireEvents)

  Programmatically selects the specified tab.

  Parameters:
    `index` - the index of the tab to be selected
    `fireEvents` - true to fire events, false not to

### selectTab

    public void selectTab(IsWidget child)

  Convenience overload to allow `IsWidget` to be used directly.

### selectTab

    public void selectTab(IsWidget child,
                          boolean fireEvents)

  Convenience overload to allow `IsWidget` to be used directly.

### selectTab

    public void selectTab(Widget child)

  Programmatically selects the specified tab and fires events.

  Parameters:
    `child` - the child whose tab is to be selected

### selectTab

    public void selectTab(Widget child,
                          boolean fireEvents)

  Programmatically selects the specified tab.

  Parameters:
    `child` - the child whose tab is to be selected
    `fireEvents` - true to fire events, false not to

### setAnimationDuration

    public void setAnimationDuration(int duration)

  Set the duration of the animated transition between tabs.

  Parameters:
    `duration` - the duration in milliseconds.

### setAnimationVertical

    public void setAnimationVertical(boolean isVertical)

  Set whether or not transitions slide in vertically or horizontally.

  Parameters:
    `isVertical` - true for vertical transitions, false for horizontal

### setTabHTML

    public void setTabHTML(int index,
                           java.lang.String html)

  Sets a tab's HTML contents. Use care when setting an object's HTML; it is an easy way to expose script-based security problems. Consider using `setTabHTML(int, SafeHtml)` or `setTabText(int, String)` whenever possible.

  Parameters:
    `index` - the index of the tab whose HTML is to be set
    `html` - the tab's new HTML contents

### setTabHTML

    public void setTabHTML(int index,
                           SafeHtml html)

  Sets a tab's HTML contents.

  Parameters:
    `index` - the index of the tab whose HTML is to be set
    `html` - the tab's new HTML contents

### setTabText

    public void setTabText(int index,
                           java.lang.String text)

  Sets a tab's text contents.

  Parameters:
    `index` - the index of the tab whose text is to be set
    `text` - the object's new text

GWT 2.7.0