@Tag(value="vaadin-menu-bar") @JsModule(value="./menubarConnector.js") @JsModule(value="@vaadin/vaadin-menu-bar/src/vaadin-menu-bar.js") @NpmPackage(value="@vaadin/vaadin-menu-bar", version="1.1.0") public class MenuBar extends Component implements HasMenuItems, HasSize, HasStyle, HasTheme
vaadin-menu-bar
element.Constructor and Description |
---|
MenuBar()
Creates an empty menu bar component.
|
Modifier and Type | Method and Description |
---|---|
MenuItem |
addItem(Component component)
Creates a new
MenuItem component and adds it to the root level of
this menu bar. |
MenuItem |
addItem(Component component,
ComponentEventListener<ClickEvent<MenuItem>> clickListener)
Creates a new
MenuItem component with the provided click listener
and adds it to the root level of this menu bar. |
MenuItem |
addItem(String text)
Creates a new
MenuItem component with the provided text content
and adds it to the root level of this menu bar. |
MenuItem |
addItem(String text,
ComponentEventListener<ClickEvent<MenuItem>> clickListener)
Creates a new
MenuItem component with the provided text content
and click listener and adds it to the root level of this menu bar. |
void |
addThemeVariants(MenuBarVariant... variants)
Adds theme variants to the component.
|
Stream<Component> |
getChildren()
Gets the child components of this menu bar.
|
List<MenuItem> |
getItems()
Gets the
MenuItem components added to the root level of the menu
bar. |
boolean |
isOpenOnHover()
Gets whether the sub menus open by clicking or hovering on the root level
buttons.
|
void |
remove(MenuItem... items)
Removes the given item components from this menu bar.
|
void |
removeAll()
Removes all item components from this menu bar.
|
void |
removeThemeVariants(MenuBarVariant... variants)
Removes theme variants from the component.
|
void |
setOpenOnHover(boolean openOnHover)
Sets the event which opens the sub menus of the root level buttons.
|
addListener, fireEvent, from, get, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeightFull, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFull
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
getElement
addAttachListener
addDetachListener
public MenuBar()
Use addItem(String)
to add content to the menu bar.
public MenuItem addItem(String text)
MenuItem
component with the provided text content
and adds it to the root level of this menu bar.
The added MenuItem
component is placed inside a button in the
menu bar. If this button overflows the menu bar horizontally, the
MenuItem
is moved out of the button, into a context menu openable
via an overflow button at the end of the button row.
To add content to the sub menu opened by clicking the root level item,
use MenuItemBase.getSubMenu()
.
text
- the text content for the new itemMenuItem
componentpublic MenuItem addItem(Component component)
MenuItem
component and adds it to the root level of
this menu bar. The provided component is added into the created
MenuItem
.
The added MenuItem
component is placed inside a button in the
menu bar. If this button overflows the menu bar horizontally, the
MenuItem
is moved out of the button, into a context menu openable
via an overflow button at the end of the button row.
To add content to the sub menu opened by clicking the root level item,
use MenuItemBase.getSubMenu()
.
component
- the component to add inside new itemMenuItem
componentpublic MenuItem addItem(String text, ComponentEventListener<ClickEvent<MenuItem>> clickListener)
MenuItem
component with the provided text content
and click listener and adds it to the root level of this menu bar.
The added MenuItem
component is placed inside a button in the
menu bar. If this button overflows the menu bar horizontally, the
MenuItem
is moved out of the button, into a context menu openable
via an overflow button at the end of the button row.
To add content to the sub menu opened by clicking the root level item,
use MenuItemBase.getSubMenu()
.
addItem
in interface HasMenuItems
text
- the text content for the new itemclickListener
- the handler for clicking the new item, can be null
to
not add listenerMenuItem
componentHasMenuItems.addItem(Component, ComponentEventListener)
,
ContextMenuBase.add(Component...)
,
SubMenuBase.add(Component...)
public MenuItem addItem(Component component, ComponentEventListener<ClickEvent<MenuItem>> clickListener)
MenuItem
component with the provided click listener
and adds it to the root level of this menu bar. The provided component is
added into the created MenuItem
.
The added MenuItem
component is placed inside a button in the
menu bar. If this button overflows the menu bar horizontally, the
MenuItem
is moved out of the button, into a context menu openable
via an overflow button at the end of the button row.
To add content to the sub menu opened by clicking the root level item,
use MenuItemBase.getSubMenu()
.
addItem
in interface HasMenuItems
component
- the component to add inside the added menu itemclickListener
- the handler for clicking the new item, can be null
to
not add listenerMenuItem
componentHasMenuItems.addItem(String, ComponentEventListener)
,
ContextMenuBase.add(Component...)
,
SubMenuBase.add(Component...)
public List<MenuItem> getItems()
MenuItem
components added to the root level of the menu
bar.
To manage the contents inside the sub menus, use the
MenuItemBase.getSubMenu()
.
MenuItem
components added to this menu barpublic void remove(MenuItem... items)
items
- the item components to remove, not null
IllegalArgumentException
- if any of the item components to remove is not a child of
this menu barpublic void removeAll()
public Stream<Component> getChildren()
The returned components are the same as the ones returned by
getItems()
.
getChildren
in class Component
Id
public void setOpenOnHover(boolean openOnHover)
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 addThemeVariants(MenuBarVariant... variants)
variants
- theme variants to addpublic void removeThemeVariants(MenuBarVariant... variants)
variants
- theme variants to removeCopyright © 2020. All rights reserved.