Package 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:
HasAttachHandlers,HasBeforeSelectionHandlers<Integer>,HasSelectionHandlers<Integer>,HasHandlers,EventListener,HasAnimation,HasVisibility,HasWidgets,IndexedPanel,IndexedPanel.ForIsWidget,IsRenderable,IsWidget,SourcesTabEvents,TabListener,Iterable<Widget>,EventListener
- Direct Known Subclasses:
DecoratedTabPanel
public class TabPanel
extends Composite
implements TabListener, SourcesTabEvents, HasWidgets, HasAnimation, IndexedPanel.ForIsWidget, HasBeforeSelectionHandlers<Integer>, HasSelectionHandlers<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.
This widget will only work in quirks mode. If your application is in
Standards Mode, use TabLayoutPanel instead.
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);
}
}
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
HasWidgets.ForIsWidgetNested classes/interfaces inherited from interface com.google.gwt.user.client.ui.IndexedPanel
IndexedPanel.ForIsWidget -
Field Summary
Fields inherited from class com.google.gwt.user.client.ui.Widget
eventsToSinkFields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConvenience overload to allowIsWidgetto be used directly.voidConvenience overload to allowIsWidgetto be used directly.voidConvenience overload to allowIsWidgetto be used directly.voidAdds a child widget.voidAdds a widget to the tab panel.voidAdds a widget to the tab panel.voidAdds a widget to the tab panel.Adds aBeforeSelectionEventhandler.addSelectionHandler(SelectionHandler<Integer> handler) Adds aSelectionEventhandler.voidaddTabListener(TabListener listener) Deprecated.voidclear()Removes all child widgets.protected SimplePanelCreate aSimplePanelthat will wrap the contents in a tab.Gets the deck panel within this tab panel.Gets the tab bar within this tab panel.getWidget(int index) Gets the child widget at the specified index.intGets the number of child widgets in this panel.intgetWidgetIndex(IsWidget child) Convenience overload to allowIsWidgetto be used directly.intgetWidgetIndex(Widget widget) Gets the index of the specified child widget.voidConvenience overload to allowIsWidgetto be used directly.voidConvenience overload to allowIsWidgetto be used directly.voidConvenience overload to allowIsWidgetto be used directly.voidInserts a widget into the tab panel.voidInserts a widget into the tab panel.voidInserts a widget into the tab panel.booleanReturns true if animations are enabled, false if not.iterator()Gets an iterator for the contained widgets.booleanonBeforeTabSelected(SourcesTabEvents sender, int tabIndex) protected voidonEnsureDebugId(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.voidonTabSelected(SourcesTabEvents sender, int tabIndex) Deprecated.booleanremove(int index) Removes the widget at the specified index.booleanRemoves the given widget, and its associated tab.voidremoveTabListener(TabListener listener) Deprecated.Use theHandlerRegistration.removeHandler()method on the object returned by and add*Handler method insteadvoidselectTab(int index) Programmatically selects the specified tab and fires events.voidselectTab(int index, boolean fireEvents) Programmatically selects the specified tab.voidsetAnimationEnabled(boolean enable) Enable or disable animations.Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidgetMethods 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, unsinkEventsMethods 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, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEventMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
TabPanel
public TabPanel()Creates an empty tab panel.
-
-
Method Details
-
add
Convenience overload to allowIsWidgetto be used directly. -
add
Convenience overload to allowIsWidgetto be used directly. -
add
Convenience overload to allowIsWidgetto be used directly. -
add
Description copied from interface:HasWidgetsAdds a child widget.- Specified by:
addin interfaceHasWidgets- Parameters:
w- the widget to be added
-
add
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 addedtabText- the text to be shown on its tab
-
add
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 addedtabText- the text to be shown on its tabasHTML-trueto treat the specified text as HTML
-
add
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 addedtabWidget- the widget to be shown in the tab
-
addTabListener
Deprecated.Description copied from interface:SourcesTabEventsAdds a listener interface to receive click events.- Specified by:
addTabListenerin interfaceSourcesTabEvents- Parameters:
listener- the listener interface to add
-
clear
public void clear()Description copied from interface:HasWidgetsRemoves all child widgets.- Specified by:
clearin interfaceHasWidgets
-
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
Gets the tab bar within this tab panel. Adding or removing tabs from the TabBar is not supported and will throw UnsupportedOperationExceptions.- Returns:
- the tab bar
-
getWidget
Description copied from interface:IndexedPanelGets the child widget at the specified index.- Specified by:
getWidgetin interfaceIndexedPanel- Parameters:
index- the child widget's index- Returns:
- the child widget
-
getWidgetCount
public int getWidgetCount()Description copied from interface:IndexedPanelGets the number of child widgets in this panel.- Specified by:
getWidgetCountin interfaceIndexedPanel- Returns:
- the number of children
-
getWidgetIndex
Convenience overload to allowIsWidgetto be used directly.- Specified by:
getWidgetIndexin interfaceIndexedPanel.ForIsWidget
-
getWidgetIndex
Description copied from interface:IndexedPanelGets the index of the specified child widget.- Specified by:
getWidgetIndexin interfaceIndexedPanel- Parameters:
widget- the widget to be found- Returns:
- the widget's index, or
-1if it is not a child of this panel
-
insert
Convenience overload to allowIsWidgetto be used directly. -
insert
Convenience overload to allowIsWidgetto be used directly. -
insert
Convenience overload to allowIsWidgetto be used directly. -
insert
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 insertedtabText- the text to be shown on its tabasHTML-trueto treat the specified text as HTMLbeforeIndex- the index before which it will be inserted
-
insert
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 insertedtabText- the text to be shown on its tabbeforeIndex- the index before which it will be inserted
-
insert
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.
-
isAnimationEnabled
public boolean isAnimationEnabled()Description copied from interface:HasAnimationReturns true if animations are enabled, false if not.- Specified by:
isAnimationEnabledin interfaceHasAnimation
-
iterator
Description copied from interface:HasWidgetsGets an iterator for the contained widgets. This iterator is required to implementIterator.remove().- Specified by:
iteratorin interfaceHasWidgets- Specified by:
iteratorin interfaceIterable<Widget>
-
onBeforeTabSelected
Deprecated.Description copied from interface:TabListenerFired just before a tab is selected.- Specified by:
onBeforeTabSelectedin interfaceTabListener- Parameters:
sender- theTabBarorTabPanelwhose tab was selected.tabIndex- the index of the tab about to be selected- Returns:
falseto disallow the selection. If any listener returns false, then the selection will be disallowed.
-
onTabSelected
Deprecated.Description copied from interface:TabListenerFired when a tab is selected.- Specified by:
onTabSelectedin interfaceTabListener- Parameters:
sender- theTabBarorTabPanelwhose tab was selectedtabIndex- the index of the tab that was selected
-
remove
public boolean remove(int index) Description copied from interface:IndexedPanelRemoves the widget at the specified index.- Specified by:
removein interfaceIndexedPanel- Parameters:
index- the index of the widget to be removed- Returns:
falseif the widget is not present
-
remove
Removes the given widget, and its associated tab.- Specified by:
removein interfaceHasWidgets- Parameters:
widget- the widget to be removed- Returns:
trueif the widget was present
-
removeTabListener
Deprecated.Use theHandlerRegistration.removeHandler()method on the object returned by and add*Handler method insteadDescription copied from interface:SourcesTabEventsRemoves a previously added listener interface.- Specified by:
removeTabListenerin interfaceSourcesTabEvents- Parameters:
listener- the listener interface to remove
-
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 selectedfireEvents- true to fire events, false not to
-
setAnimationEnabled
public void setAnimationEnabled(boolean enable) Description copied from interface:HasAnimationEnable or disable animations.- Specified by:
setAnimationEnabledin interfaceHasAnimation- Parameters:
enable- true to enable, false to disable
-
createTabTextWrapper
Create aSimplePanelthat will wrap the contents in a tab. Subclasses can use this method to wrap tabs in decorator panels.- Returns:
- a
SimplePanelto wrap the tab contents, or null to leave tabs unwrapped
-
onEnsureDebugId
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:
onEnsureDebugIdin classUIObject- Parameters:
baseID- the base ID used by the main element- See Also:
-
addBeforeSelectionHandler(com.google.gwt.event.logical.shared.BeforeSelectionHandler<java.lang.Integer>)andaddSelectionHandler(com.google.gwt.event.logical.shared.SelectionHandler<java.lang.Integer>)instead