Interface DropdownButtonComponent

All Superinterfaces:
HasSubParts
All Known Implementing Classes:
AbstractDropdownButton, ComboButton, DropdownButton

public interface DropdownButtonComponent extends HasSubParts
Represents a UI component providing functionality for managing dropdown items.
  • Method Details

    • addItem

      DropdownButtonItem addItem(String id, Action action)
      Adds a new dropdown item with the specified identifier and action.
      Parameters:
      id - the identifier for the dropdown item
      action - the action to associate with the dropdown item
      Returns:
      the created dropdown item
    • addItem

      DropdownButtonItem addItem(String id, Action action, int index)
      Adds a new dropdown item with the specified identifier, action, and index.
      Parameters:
      id - the identifier for the dropdown item
      action - the action to associate with the dropdown item
      index - the position at which the dropdown item will be added
      Returns:
      the created dropdown item
    • addItem

      DropdownButtonItem addItem(String id, String text)
      Adds a new dropdown item with the specified identifier and text.
      Parameters:
      id - the identifier for the dropdown item
      text - the text to display for the dropdown item
      Returns:
      the created dropdown item
    • addItem

      DropdownButtonItem addItem(String id, String text, int index)
      Adds a new dropdown item with the specified identifier, text, and index.
      Parameters:
      id - the identifier for the dropdown item
      text - the text to display for the dropdown item
      index - 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 item
      text - the text displayed for the dropdown item
      componentEventListener - 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 item
      text - the text to display for the dropdown item
      componentEventListener - the listener to handle click events for the dropdown item
      index - 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)
      Adds a new dropdown item with the specified identifier and component content.
      Parameters:
      id - the unique identifier for the dropdown item
      component - the component to be used as content for the dropdown item
      Returns:
      the created dropdown item instance
    • addItem

      DropdownButtonItem addItem(String id, com.vaadin.flow.component.Component component, int index)
      Adds a new dropdown item with the specified identifier, component content, and position index.
      Parameters:
      id - the unique identifier for the dropdown item
      component - the component to be used as content for the dropdown item
      index - 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 item
      component - the component to be used as content for the dropdown item
      componentEventListener - 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 item
      component - the component to be used as content for the dropdown item
      componentEventListener - the listener to handle click events for the dropdown item
      index - the position at which the dropdown item will be added
      Returns:
      the created dropdown item instance
    • getItem

      @Nullable DropdownButtonItem getItem(String itemId)
      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

      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

      void remove(String itemId)
      Removes the specified item identified by the given item ID.
      Parameters:
      itemId - the unique identifier of the item to be removed
    • remove

      void remove(DropdownButtonItem item)
      Removes the specified item from the collection or list.
      Parameters:
      item - the item to be removed
    • remove

      void remove(DropdownButtonItem... items)
      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 - if true, the dropdown menu will open on hover; if false, 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 be null 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

      @Nullable default Object getSubPart(String name)
      Description copied from interface: HasSubParts
      Returns a sub part object by its name.
      Specified by:
      getSubPart in interface HasSubParts
      Parameters:
      name - sub part name, e.g. component id
      Returns:
      a sub part object by its name, or null if not found