Interface DropdownButtonItem
- All Known Subinterfaces:
AbstractDropdownButton.HasMenuItem
,ActionItem
,ComponentItem
,TextItem
- All Known Implementing Classes:
AbstractDropdownButton.AbstractDropdownButtonItem
,AbstractDropdownButton.ActionItemImpl
,AbstractDropdownButton.ComponentItemImpl
,AbstractDropdownButton.TextItemImpl
public interface DropdownButtonItem
Represents an item that can be included in a dropdown button component.
Defines the common behavior for items such as visibility, enabling/disabling,
and handling click events.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Represents a click event triggered by aDropdownButtonItem
. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.Registration
Adds a listener to handle click events for the dropdown button item.getId()
Returns the unique identifier of the dropdown button item.Returns the parent dropdown button component to which this item belongs.boolean
Checks whether the dropdown button item is currently enabled.boolean
Checks whether the dropdown button item is currently visible.void
setEnabled
(boolean enabled) Enables or disables the dropdown button item.void
setVisible
(boolean visible) Sets the visibility of the dropdown button item.
-
Method Details
-
getParent
DropdownButtonComponent getParent()Returns the parent dropdown button component to which this item belongs.- Returns:
- the parent
DropdownButtonComponent
of this item
-
getId
String getId()Returns the unique identifier of the dropdown button item.- Returns:
- the identifier of the item as a string, or null if not set
-
setVisible
void setVisible(boolean visible) Sets the visibility of the dropdown button item. A visible item is rendered and can interact with users, while an invisible item is not displayed and cannot be interacted with.- Parameters:
visible
- if true, the item will be visible; otherwise, it will be hidden
-
isVisible
boolean isVisible()Checks whether the dropdown button item is currently visible. A visible item is displayed in the dropdown and can interact with users, whereas an invisible item is hidden and cannot be interacted with.- Returns:
- true if the item is visible, false otherwise
-
setEnabled
void setEnabled(boolean enabled) Enables or disables the dropdown button item. When the item is disabled, it cannot be interacted with.- Parameters:
enabled
- iftrue
, the item will be enabled; otherwise, it will be disabled
-
isEnabled
boolean isEnabled()Checks whether the dropdown button item is currently enabled. An enabled item can be interacted with, whereas a disabled item cannot.- Returns:
true
if the item is enabled,false
otherwise
-
addClickListener
com.vaadin.flow.shared.Registration addClickListener(Consumer<DropdownButtonItem.ClickEvent> listener) Adds a listener to handle click events for the dropdown button item. When the item is clicked, the providedConsumer
processes the associatedDropdownButtonItem.ClickEvent
.- Parameters:
listener
- theConsumer
to handle theDropdownButtonItem.ClickEvent
triggered by a click on the item- Returns:
- a
Registration
object that can be used to remove the added listener
-