Reuse Menu on numerous views

As I build more and more views, I copy-paste the menu and actions to other views/pages.
Is there any way to define the menu system once, and re-use it on other views/classes?

I have a sneaking suspicion that you aren’t using Vaadin as a true web application. In Vaadin, there aren’t any pages at all. Instead, navigation is accomplished by replacing one sublayout with another. In your case, you should create a main layout (eg horizontal layout), and place the menu and your content in that layout. When navigating, only replace the content part (e.g. mainlayout.replaceComponent(oldLayout, newLayout), not the whole content. You’ll find that your menu will stay in place even though the content changes.

I’ve been making the whole class a ‘layout’ by extending HorizontalLayout. Maybe I don’t want to do that?

I have been using the method navigateTo(“View2”) and this replaces everything, because everything was in the layout?

In that case you are well on your way to the correct solution. Using the Navigator, you can specify where the view is rendered, it doesn’t need to be the complete screen. In your UI class:

[code]
VerticalLayout vl= new VerticalLayout();
setContent(vl);

Menu menu= new Menu();
vl.addComponent(menu);

Panel panel= new Panel();
vl.addComponent(panel);

Navigator nav = new Navigator(this, panel);
[/code]Now your views will be rendered in the Panel, not the whole UI.

Got it working following your example. Thanks!