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 can add tabs using the same techniques described before and you can register the same SelectedTabChangeListener
. Here is a screenshot of the just developed accordion: