Interface DropdownButtonComponent
- All Superinterfaces:
HasSubParts
- All Known Implementing Classes:
AbstractDropdownButton
,ComboButton
,DropdownButton
Represents a UI component providing functionality for managing dropdown items.
-
Method Summary
Modifier and TypeMethodDescriptionAdds a new dropdown item with the specified identifier and component content.Adds a new dropdown item with the specified identifier, component content, and position index.addItem
(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Adds a new dropdown item with the specified identifier, content component, and a click event listener.addItem
(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Adds a new dropdown item with the specified identifier, component content, click event listener, and position index.Adds a new dropdown item with the specified identifier and action.Adds a new dropdown item with the specified identifier, action, and index.Adds a new dropdown item with the specified identifier and text.Adds a new dropdown item with the specified identifier, text, and index.addItem
(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Adds a new dropdown item with the specified identifier, text, and a click event listener.addItem
(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Adds a new dropdown item with the specified identifier, text, click event listener, and position index.void
Adds a visual separator to the dropdown menu.void
addSeparatorAtIndex
(int index) Adds a visual separator at the specified index in the dropdown menu.com.vaadin.flow.component.icon.Icon
getIcon()
Returns the icon associated with the dropdown button item, if present.Returns the dropdown item with the specified identifier.getItems()
Returns a list of all items currently present in the dropdown button component.default Object
getSubPart
(String name) Returns a sub part object by its name.boolean
Determines whether the dropdown menu is configured to open when the user hovers over the component.void
remove
(DropdownButtonItem item) Removes the specified item from the collection or list.void
remove
(DropdownButtonItem... items) Removes the specified items from the dropdown button's list of items.void
Removes the specified item identified by the given item ID.void
Removes all items from the dropdown button component.void
setIcon
(com.vaadin.flow.component.icon.Icon icon) Sets the icon for the component.void
setOpenOnHover
(boolean openOnHover) Configures whether the dropdown menu opens when the user hovers over the button.
-
Method Details
-
addItem
Adds a new dropdown item with the specified identifier and action.- Parameters:
id
- the identifier for the dropdown itemaction
- the action to associate with the dropdown item- Returns:
- the created dropdown item
-
addItem
Adds a new dropdown item with the specified identifier, action, and index.- Parameters:
id
- the identifier for the dropdown itemaction
- the action to associate with the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item
-
addItem
Adds a new dropdown item with the specified identifier and text.- Parameters:
id
- the identifier for the dropdown itemtext
- the text to display for the dropdown item- Returns:
- the created dropdown item
-
addItem
Adds a new dropdown item with the specified identifier, text, and index.- Parameters:
id
- the identifier for the dropdown itemtext
- the text to display for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item
-
addItem
DropdownButtonItem addItem(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Adds a new dropdown item with the specified identifier, text, and a click event listener.- Parameters:
id
- the unique identifier for the dropdown itemtext
- the text displayed for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown item- Returns:
- the created dropdown item instance
-
addItem
DropdownButtonItem addItem(String id, String text, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Adds a new dropdown item with the specified identifier, text, click event listener, and position index.- Parameters:
id
- the unique identifier for the dropdown itemtext
- the text to display for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item instance
-
addItem
Adds a new dropdown item with the specified identifier and component content.- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown item- Returns:
- the created dropdown item instance
-
addItem
Adds a new dropdown item with the specified identifier, component content, and position index.- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item instance
-
addItem
DropdownButtonItem addItem(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener) Adds a new dropdown item with the specified identifier, content component, and a click event listener.- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown item- Returns:
- the created dropdown item instance
-
addItem
DropdownButtonItem addItem(String id, com.vaadin.flow.component.Component component, Consumer<DropdownButtonItem.ClickEvent> componentEventListener, int index) Adds a new dropdown item with the specified identifier, component content, click event listener, and position index.- Parameters:
id
- the unique identifier for the dropdown itemcomponent
- the component to be used as content for the dropdown itemcomponentEventListener
- the listener to handle click events for the dropdown itemindex
- the position at which the dropdown item will be added- Returns:
- the created dropdown item instance
-
getItem
Returns the dropdown item with the specified identifier.- Parameters:
itemId
- the unique identifier of the dropdown item to retrieve- Returns:
- the item with the given identifier, or
null
if no item with the specified ID is found
-
getItems
List<DropdownButtonItem> getItems()Returns a list of all items currently present in the dropdown button component.- Returns:
- a list of
DropdownButtonItem
instances representing all items in the dropdown.
-
remove
Removes the specified item identified by the given item ID.- Parameters:
itemId
- the unique identifier of the item to be removed
-
remove
Removes the specified item from the collection or list.- Parameters:
item
- the item to be removed
-
remove
Removes the specified items from the dropdown button's list of items.- Parameters:
items
- the items to be removed from the dropdown button. Each item represents a DropdownButtonItem object to be excluded from the list.
-
removeAll
void removeAll()Removes all items from the dropdown button component. -
addSeparator
void addSeparator()Adds a visual separator to the dropdown menu. Separators are used to group related items visually. -
addSeparatorAtIndex
void addSeparatorAtIndex(int index) Adds a visual separator at the specified index in the dropdown menu. Separators are used to visually group related items within the menu.- Parameters:
index
- the position at which the separator will be added. The index must be a non-negative integer less than or equal to the current number of items.
-
setOpenOnHover
void setOpenOnHover(boolean openOnHover) Configures whether the dropdown menu opens when the user hovers over the button.- Parameters:
openOnHover
- iftrue
, the dropdown menu will open on hover; iffalse
, it will only open on click
-
isOpenOnHover
boolean isOpenOnHover()Determines whether the dropdown menu is configured to open when the user hovers over the component.- Returns:
true
if the dropdown opens on hover,false
otherwise
-
setIcon
void setIcon(@Nullable com.vaadin.flow.component.icon.Icon icon) Sets the icon for the component.- Parameters:
icon
- the icon to set. Can benull
to clear the current icon.
-
getIcon
@Nullable com.vaadin.flow.component.icon.Icon getIcon()Returns the icon associated with the dropdown button item, if present.- Returns:
- the icon of the dropdown button item, or
null
if no icon is set
-
getSubPart
Description copied from interface:HasSubParts
Returns a sub part object by its name.- Specified by:
getSubPart
in interfaceHasSubParts
- Parameters:
name
- sub part name, e.g. component id- Returns:
- a sub part object by its name, or
null
if not found
-