如何在vaadin中动态添加Tabs?

Kum*_*mar 1 java user-interface vaadin

我想知道如何在vaadin标签页中动态添加标签.我有TabSheet,它包含两个选项卡.第一个选项卡有一个按钮.如果我们点击该按钮,那么另一个选项卡应该在标签页中动态添加.任何人都可以告诉我如何实现这一点.

Dan*_*iel 5

在此处查看演示,代码示例和API文档.

final TabSheet tabSheet = new TabSheet();

Button button = new Button("Add the tab");
button.addListener(new Button.ClickListener(){
    public void buttonClick(ClickEvent event) {
        VerticalLayout content = new VerticalLayout();
        content.addComponent(new Label("This is the tab content."));
        Tab tab = tabSheet.addTab(content, "The new Tab", null);
    }
}
Run Code Online (Sandbox Code Playgroud)