Class MenuItem

All Implemented Interfaces:
AttachNotifier, ClickNotifier<MenuItem>, DetachNotifier, HasAriaLabel, HasComponents, HasElement, HasEnabled, HasStyle, HasText, Serializable

public class MenuItem extends MenuItemBase<ContextMenu,MenuItem,SubMenu> implements ClickNotifier<MenuItem>
Item component used inside ContextMenu and SubMenu. This component can be created and added to a menu overlay with HasMenuItems.addItem(String, ComponentEventListener) and similar methods.
Author:
Vaadin Ltd.
See Also:
  • Constructor Details

  • Method Details

    • createSubMenu

      protected SubMenu createSubMenu()
      Specified by:
      createSubMenu in class MenuItemBase<ContextMenu,MenuItem,SubMenu>
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets the menu item explicitly disabled or enabled. When disabled, menu items are rendered as "dimmed".

      By default, disabled items are not focusable and don't react to hover. As a result, they are hidden from assistive technologies, and it's not possible to show a tooltip to explain why they are disabled. This can be addressed by enabling the feature flag accessibleDisabledMenuItems, which makes disabled items focusable and hoverable, while still preventing them from being activated. To enable this feature flag, add the following line to src/main/resources/vaadin-featureflags.properties:

       com.vaadin.experimental.accessibleDisabledMenuItems = true
       
      Specified by:
      setEnabled in interface HasEnabled
      Overrides:
      setEnabled in class MenuItemBase<ContextMenu,MenuItem,SubMenu>
      Parameters:
      enabled - if false then explicitly disables the object, if true then enables the object so that its state depends on parent