Vaadin Web应用开发教程(35):UI布局-Accordion布局

jerry VaadinWeb 2015年11月25日 收藏

Accordion布局类似TabSheet,不过是以垂直方式安排多个标签页,其使用方法也和TabSheet布局类似。

  1. // Create the Accordion.
  2. Accordion accordion = new Accordion();
  3. // Have it take all space available in the layout.
  4. accordion.setSizeFull();
  5. // Some components to put in the Accordion.
  6. Label l1 = new Label("There are no previously saved actions.");
  7. Label l2 = new Label("There are no saved notes.");
  8. Label l3 = new Label("There are currently no issues.");
  9. // Add the components as tabs in the Accordion.
  10. accordion.addTab(l1, "Saved actions", null);
  11. accordion.addTab(l2, "Notes", null);
  12. accordion.addTab(l3, "Issues", null);
  13. // A container for the Accordion.
  14. Panel panel = new Panel("Tasks");
  15. panel.setWidth("300px");
  16. panel.setHeight("300px");
  17. panel.addComponent(accordion);
  18. // Trim its layout to allow the Accordion take all space.
  19. panel.getLayout().setSizeFull();
  20. panel.getLayout().setMargin(false);