Menu calling classes, or view

Hello good afternoon!

Dear today with the help of examples
build the menu, most unfortunately what the swing is quiet in vaadin’m picking up ugly, met along the way such a navigator and could not make it work then peopl who can assess what I did (better what I copied) and where I am going wrong .

Note. The menu is being rendered can not call the classes linked to the menu, does not give any error, do not simply nothing.

    protected void init(VaadinRequest request) {
        setLocale(new Locale("pt", "BR"));
        VerticalLayout layout = new VerticalLayout();
        // Mostrar uma view controlada pelo navigator
        Panel viewDisplay = new Panel();
        // Criar um navigator
        Navigator navigator = new Navigator(this, viewDisplay);
        //navigator.addView("beverages", new MyView("Beverages View"));
        //navigator.addView("snacks",    new MyView("Snacks View"));
        //navigator.addView("Serviços",  new MyView("Services View"));
        navigator.addView("Beverages", new Beverages()  ); 
        navigator.addView("Snacks", new Snacks()  ); 
        NavigableMenuBar menu = new NavigableMenuBar(navigator);
        layout.setExpandRatio(viewDisplay, 1.0f);
        menu.addView("Beverages", "Beverages", null);
        menu.addView("Snacks", "Snacks", null);

Robson - Brazil

menu.addView("Beverages", "Beverages", null); menu.addView("Snacks", "Snacks", null) instead of null (third parameter) pass an instance of Menu.Command class.

Hello Good morning!

Vikrant Thanks for the feedback. I will proceed as recommended and put the return.

Olá bom dia!

Vikrant Obrigado pelo retorno. Vou proceder como recomendado e posto o retorno.


I did not see how to proceed because the third parameter is an icon, menu is a NavigableMenuBar object

the example

class NavigableMenuBar extends MenuBar implements ViewChangeListener {
    HashMap<String,MenuItem> menuItems = new HashMap<String,MenuItem>();
    private Navigator navigator = null;
    public NavigableMenuBar(Navigator navigator) {
        this.navigator = navigator;
    MenuBar.Command mycommand = new MenuBar.Command() {

        public void menuSelected(MenuItem selectedItem) {
            String viewName = selectItem(selectedItem);
    public void addView(String viewName, String caption, Resource icon) {
        menuItems.put(viewName, addItem(caption, icon, mycommand));

Probably you could allow remote access to your computer, so that I could look into your code.


I can send you the zip project file.

now I’m at work and need to ask permission to access industry, I’m on lunch break that is the time I take to study Java, JSF, Vaadin

The project is small, only have 5 classes ie is equal to the example of vaadin the page with minor changes



You forgot to add the components in the Layout / View which is the Snacks and Beverages.

Você esqueceu de adicionar os componentes no Layout/View que é o Snacks e Beverages. &&



Dear Pedro okay? so I was thinking it would not receive another return, the error that is lacking I insert these two classes this information you provided, I will do as suggested and post the application behavior.

Hi Pedro!

It worked! Was 15 days with the problem and now worked and all because of a little more accurate your comment.

Well I confess that my Java is not there these things, but now I can go ahead and try to do some screens since the menu is running.

Thank you so much.

disponha (:
if you need support, you can contact me. I’m From Brazil too.

skype: gpedro842

This example works fine for single menu items. Can anybody post the same example with submenu please?

I’ve uploaded example on my github. Please checkout.