Interface DropdownButtonItem
- All Known Subinterfaces:
AbstractDropdownButton.HasMenuItem,ActionItem,ComponentItem,TextItem
- All Known Implementing Classes:
AbstractDropdownButton.AbstractDropdownButtonItem,AbstractDropdownButton.ActionItemImpl,AbstractDropdownButton.ComponentItemImpl,AbstractDropdownButton.SeparatorUserMenuItem,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 classRepresents a click event triggered by aDropdownButtonItem. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationAdds 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.booleanChecks whether the dropdown button item is currently enabled.booleanChecks whether the dropdown button item is currently visible.voidsetEnabled(boolean enabled) Enables or disables the dropdown button item.voidsetVisible(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
DropdownButtonComponentof 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:
trueif the item is enabled,falseotherwise
-
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 providedConsumerprocesses the associatedDropdownButtonItem.ClickEvent.- Parameters:
listener- theConsumerto handle theDropdownButtonItem.ClickEventtriggered by a click on the item- Returns:
- a
Registrationobject that can be used to remove the added listener
-