Package com.vaadin.flow.component.tabs
Class TabSheet
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.tabs.TabSheet
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasSize,HasStyle,HasTheme,HasPrefix,HasSuffix,HasThemeVariant<TabSheetVariant>,Serializable
@Tag("vaadin-tabsheet")
@NpmPackage(value="@vaadin/tabsheet",
version="24.9.5")
@JsModule("@vaadin/tabsheet/src/vaadin-tabsheet.js")
public class TabSheet
extends Component
implements HasPrefix, HasStyle, HasSize, HasSuffix, HasThemeVariant<TabSheetVariant>
TabSheet consists of a set of tabs and the content area. The content area
displays a component associated with the selected tab.
- Author:
- Vaadin Ltd.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn event to mark that the selected tab has changed. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a tab created from the given tab content and content.Adds a tab with the given content.Adds a tab with the given content to the given position.Adds a tab created from the given text and content.Adds a listener forTabSheet.SelectedChangeEvent.getComponent(Tab tab) Returns theComponentinstance associated with the given tab.intgetIndexOf(Tab tab) Returns the index of the given tab.intGets the zero-based index of the currently selected tab.Gets the currently selected tab.Returns theTabassociated with the given component.getTabAt(int position) Returns the tab at the given position.intGets the number of tabs.voidremove(int position) Removes the tab at the given position.voidRemoves a tab based on the contentvoidRemoves a tab.voidsetSelectedIndex(int selectedIndex) Selects a tab based on its zero-based index.voidsetSelectedTab(Tab selectedTab) Selects the given tab.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
-
Constructor Details
-
TabSheet
public TabSheet()The default constructor.
-
-
Method Details
-
add
Adds a tab created from the given text and content.- Parameters:
tabText- the text of the tabcontent- the content related to the tab- Returns:
- the created tab
-
add
Adds a tab created from the given tab content and content.- Parameters:
tabContent- the content of the tabcontent- the content related to the tab- Returns:
- the created tab
-
add
Adds a tab with the given content.- Parameters:
tab- the tabcontent- the content related to the tab- Returns:
- the added tab
-
add
Adds a tab with the given content to the given position.- Parameters:
tab- the tabcontent- the content related to the tabposition- the position where the tab should be added. If negative, the tab is added at the end.- Returns:
- the added tab
-
remove
Removes a tab.- Parameters:
tab- the non-null tab to be removed
-
remove
Removes a tab based on the content- Parameters:
content- the non-null content related to the tab to be removed
-
remove
public void remove(int position) Removes the tab at the given position.- Parameters:
position- the position of the tab to be removed
-
getSelectedIndex
public int getSelectedIndex()Gets the zero-based index of the currently selected tab.- Returns:
- the zero-based index of the selected tab, or -1 if none of the tabs is selected
-
setSelectedIndex
public void setSelectedIndex(int selectedIndex) Selects a tab based on its zero-based index.- Parameters:
selectedIndex- the zero-based index of the selected tab, -1 to unselect all
-
getSelectedTab
Gets the currently selected tab.- Returns:
- the selected tab, or
nullif none is selected
-
setSelectedTab
Selects the given tab.- Parameters:
selectedTab- the tab to select,nullto unselect all- Throws:
IllegalArgumentException- ifselectedTabis not a child of this component
-
getTabCount
public int getTabCount()Gets the number of tabs.- Returns:
- the number of tabs
-
getTabAt
Returns the tab at the given position.- Parameters:
position- the position of the tab, must be greater than or equals to 0 and less than the number of tabs- Returns:
- The tab at the given index
- Throws:
IllegalArgumentException- if the index is less than 0 or greater than or equals to the number of tabs
-
getIndexOf
Returns the index of the given tab.- Parameters:
tab- the tab to look up, can not benull- Returns:
- the index of the tab or -1 if the tab is not added
-
getTab
Returns theTabassociated with the given component.- Parameters:
content- the component to look up, can not benull- Returns:
- The tab instance associated with the given component, or
nullif theTabSheetdoes not contain the component.
-
getComponent
Returns theComponentinstance associated with the given tab.- Parameters:
tab- the tab to look up, can not benull- Returns:
- The component instance associated with the given tab, or
nullif theTabSheetdoes not contain the tab.
-
addSelectedChangeListener
public Registration addSelectedChangeListener(ComponentEventListener<TabSheet.SelectedChangeEvent> listener) Adds a listener forTabSheet.SelectedChangeEvent.- Parameters:
listener- the listener to add, notnull- Returns:
- a handle that can be used for removing the listener
-