@JsModule(value="./fcEnhancedTabs/connector.js")
@CssImport(value="./fcEnhancedTabs/fc-enhanced-tabs.css") @CssImport(value="./fcEnhancedTabs/fc-enhanced-tabs-legacy.css") @CssImport(value="./fcEnhancedTabs/vaadin-menu-bar-button-legacy.css",themeFor="vaadin-menu-bar-button")
public class EnhancedTabs
extends com.vaadin.flow.component.Composite<com.vaadin.flow.component.menubar.MenuBar>
implements com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle
Tab
components can be added to this component with the add(Tab...)
method or the
#Tabs(Tab...)
constructor. The Tab components added to it can be selected with the
setSelectedIndex(int)
or setSelectedTab(Tab)
methods. The first added
Tab
component will be automatically selected, firing a EnhancedTabs.SelectedChangeEvent
,
unless autoselection is explicitly disabled with #Tabs(boolean, Tab...)
, or
setAutoselect(boolean)
. Removing the selected tab from the component changes the
selection to the next available tab.
Note: Adding or removing Tab components via the Element API, eg.
tabs.getElement().insertChild(0, tab.getElement());
, doesn't update the selected index,
so it may cause the selected tab to change unexpectedly.
Modifier and Type | Class and Description |
---|---|
static class |
EnhancedTabs.SelectedChangeEvent
An event to mark that the selected tab has changed.
|
Constructor and Description |
---|
EnhancedTabs()
Constructs an empty new object.
|
EnhancedTabs(boolean autoselect,
com.vaadin.flow.component.tabs.Tab... tabs)
Constructs a new object enclosing the given autoselect option and tabs,.
|
EnhancedTabs(com.vaadin.flow.component.tabs.Tab... tabs)
Constructs a new object enclosing the given tabs.
|
Modifier and Type | Method and Description |
---|---|
void |
add(com.vaadin.flow.component.tabs.Tab... tabs)
Adds the given tabs to the component.
|
com.vaadin.flow.shared.Registration |
addSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<EnhancedTabs.SelectedChangeEvent> listener)
Adds a listener for
EnhancedTabs.SelectedChangeEvent . |
int |
getComponentCount()
Gets the number of children tabs.
|
int |
getSelectedIndex()
Gets the zero-based index of the currently selected tab.
|
com.vaadin.flow.component.tabs.Tab |
getSelectedTab()
Gets the currently selected tab.
|
com.vaadin.flow.component.tabs.Tab |
getTabAt(int index)
Returns the tab at the given position.
|
int |
indexOf(com.vaadin.flow.component.tabs.Tab tab)
Returns the index of the given tab.
|
boolean |
isAutoselect()
Gets whether the tabs should be automatically selected.
|
boolean |
isOpenOnHover()
Gets whether the submenu opens by clicking or hovering on the overflow buttons.
|
protected void |
onAttach(com.vaadin.flow.component.AttachEvent event) |
void |
remove(com.vaadin.flow.component.tabs.Tab... tabs)
Removes the given child tabs from this component.
|
void |
removeAll()
Removes all tabs from this component.
|
void |
replace(com.vaadin.flow.component.tabs.Tab oldTab,
com.vaadin.flow.component.tabs.Tab newTab)
Replaces the tab in the container with another one without changing position.
|
void |
setAutoselect(boolean autoselect)
Specify that the tabs should be automatically selected.
|
void |
setOpenOnHover(boolean openOnHover)
Sets whether the submenu opens by clicking or hovering on the overflow buttons.
|
void |
setSelectedIndex(int selectedIndex)
Selects a tab based on its zero-based index.
|
void |
setSelectedTab(com.vaadin.flow.component.tabs.Tab selectedTab)
Selects the given tab.
|
void |
setSelectedTab(com.vaadin.flow.component.tabs.Tab selectedTab,
boolean changedFromClient) |
getChildren, getContent, getElement, initContent
addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCssSize, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
public EnhancedTabs()
public EnhancedTabs(com.vaadin.flow.component.tabs.Tab... tabs)
The first added Tab
component will be automatically selected. Any selection change
listener added afterwards will not be notified about the auto-selected tab.
tabs
- the tabs to enclosepublic EnhancedTabs(boolean autoselect, com.vaadin.flow.component.tabs.Tab... tabs)
Unless auto-select is disabled, the first added Tab
component will be automatically
selected. Any selection change listener added afterwards will not be notified about the
auto-selected tab.
autoselect
- true
to automatically select the first added tab, false
to
leave tabs unselectedtabs
- the tabs to encloseprotected void onAttach(com.vaadin.flow.component.AttachEvent event)
onAttach
in class com.vaadin.flow.component.Component
public void setOpenOnHover(boolean openOnHover)
true
.openOnHover
- true
to make the sub menus open on hover (mouseover), false
to make them openable by clickingpublic boolean isOpenOnHover()
true
if the sub menus open by hovering on the root level buttons, false
if they open by clickingpublic void add(com.vaadin.flow.component.tabs.Tab... tabs)
The first added Tab
component will be automatically selected, unless auto-selection is
explicitly disabled with #Tabs(boolean, Tab...)
, or setAutoselect(boolean)
. If
a selection change listener has been added before adding the tabs, it will be notified with the
auto-selected tab.
tabs
- the tabs to enclosepublic void remove(com.vaadin.flow.component.tabs.Tab... tabs)
tabs
- the tabs to removeIllegalArgumentException
- if there is a tab whose non null
parent is not this
component
Removing tabs before the selected tab will decrease the selected index
to avoid changing the selected tab. Removing the selected tab will
select the next available tab if autoselect is true, otherwise no tab will be selected.
public void removeAll()
This will reset the selected index
to zero.
public void replace(com.vaadin.flow.component.tabs.Tab oldTab, com.vaadin.flow.component.tabs.Tab newTab)
oldTab
- the old tab that will be replaced. Can be null
, which will make the
newTab to be added to the layout without replacing any othernewTab
- the new tab to be replaced. Can be null
, which will make the oldTab
to be removed from the layout without adding any other
Replacing the currently selected tab will make the new tab selected.
public com.vaadin.flow.shared.Registration addSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<EnhancedTabs.SelectedChangeEvent> listener)
EnhancedTabs.SelectedChangeEvent
.listener
- the listener to add, not null
public int getSelectedIndex()
public void setSelectedIndex(int selectedIndex)
selectedIndex
- the zero-based index of the selected tab, -1 to unselect allpublic com.vaadin.flow.component.tabs.Tab getSelectedTab()
null
if none is selectedpublic void setSelectedTab(com.vaadin.flow.component.tabs.Tab selectedTab)
selectedTab
- the tab to select, null
to unselect allIllegalArgumentException
- if selectedTab
is not a child of this componentpublic void setSelectedTab(com.vaadin.flow.component.tabs.Tab selectedTab, boolean changedFromClient)
public void setAutoselect(boolean autoselect)
autoselect
- true
to autoselect tab, false
to not.public boolean isAutoselect()
true
if autoselect is active, false
otherwisesetAutoselect(boolean)
public int indexOf(com.vaadin.flow.component.tabs.Tab tab)
tab
- the tab to look up, can not be null
public int getComponentCount()
public com.vaadin.flow.component.tabs.Tab getTabAt(int index)
index
- the position of the tab, must be greater than or equals to 0 and less than the
number of children tabsIllegalArgumentException
- if the index is less than 0 or greater than or equals to the
number of children tabsCopyright © 2023 Flowing Code. All rights reserved.