不幸的是,vaadin 只提供了一个菜单栏。
如果您有 html 和 css 方面的经验,您可以创建自己的垂直菜单,然后使用 vaadin CustomLayout 将其嵌入到面板中。
例如,您可以尝试这样的事情。
您应该创建一个 html 文件:
<table width="100%" height="100%">
<tr height="100%">
<td>
<table align="center">
<tr>
<td align="left">Menu 1</td>
<td><div location="menu1"></div></td>
</tr>
<tr>
<td align="right">Menu2</td>
<td><div location="menu2"></div></td>
</tr>
</table>
</td>
</tr>
</table>
然后你应该以这种方式将它嵌入到 vaadin 中:
// Have a Panel where to put the custom layout.
Panel panel = new Panel("Menu");
panel.setSizeUndefined();
main.addComponent(panel);
// Create custom layout from "yourfile.html" template.
CustomLayout custom = new CustomLayout("layoutname");
//the style name refers the one you should define in css
custom.addStyleName("customlayoutexample");
// Use it as the layout of the Panel.
panel.setContent(custom);
// Create a few components and bind them to the location tags
// in the custom layout.
TextField menu1 = new TextField();
custom.addComponent(menu1, "menu1");
TextField menu2 = new TextField();
custom.addComponent(menu2, "menu2");
注意将位置名称与组件名称绑定。
如果您想向 xml 添加一些 javascript(用于打开/关闭菜单元素),您应该直接在 tag 属性中编写它。