Trying menubar, but it fails!

Hi,
I’m new to Vaadin and trying the example from the following URL:
https://
vaadin.com/book/vaadin7/-/page/components.menubar.html

Unfortunately I can’t get it working!

MenuBar.MenuItem project = menubar.addItem("Project", null, mycommand);
[/code]The line above yields an error message: [b]
mycommand cannot be resolved to a variable
[/b], but why!?
mycommand is defined like this:
        [code]
final Label selection = new Label("-");
        layout.addComponent(selection);
        MenuBar.Command mycommand = new MenuBar.Command() {
            public void menuSelected(MenuBar.MenuItem selectedItem) {
                selection.setValue("Ordered a " +
                                   selectedItem.getText() +
                                   " from menu.");
            }
        };

Something very basic must be wrong here, but can’t figure out what!

Regards,
Gerard

The example code in the book gives the description of the command definition later, but it should be defined
before
you use it in creating the menu items.

If it’s not obvious enough, I guess the command could be described earlier in the section.

hi, I tried this example and all work fine, I attached you a screen, be sure you import correct vaadin library and not some gwt component or something else.
13493.jpg

Marko,

Thanks for your suggestion! It was indeed an ordering issue; now it works!

Regards,
Gerard