Accordions

If you know TabSheet, you already know Accordion. Really, they work exactly the same. To demonstrate this fact, let's take the code in the previous TabSheet example and change the corresponding identifiers to use Accordion instead of TabSheet.

Accordion accordion = new Accordion();
accordion.addTab(new Label("Label 1"), "Tabl 1");
accordion.addTab(new Label("Label 2")).setCaption("Tab 2");
Tab tab = accordion.addTab(new Label("Label 3"));
tab.setCaption("Tab 3");
tab.setClosable(true);

accordion
    .addSelectedTabChangeListener(new SelectedTabChangeListener() {
      public void selectedTabChange(
          SelectedTabChangeEvent event) {
        Notification.show("You are watching "
            + event.getTabSheet().getSelectedTab());
      }
    });

Everything works as expected. You ...

Get Vaadin 7 UI Design By Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.