Search code examples
vaadinmenubar

MenuBar click item listener


I got the class TopMenu which extends MenuBar vaadin component and I override method: addItem - this method is use to add items - now I got other class where I create

TopMenu topMenu = TopMenu();

and add as a component

addComponent(topMenu)

I need add listener to topMenu like:

topMenu.addListener(ClickListener...){...}

and get the item to change his styleName/layout

I can't use item command, thanks for help.


Solution

  • Try this:

    topMenu.addItemListener(...) //instead of addListener