Kliver Max
Kliver Max

Reputation: 5299

How to add content to Tab in Vaadin?

I have tabSheet with tabs.

 TabSheet tabsheet = new TabSheet();
 tabsheet.setSizeUndefined();
 tabsheet.addTab(new Label("Contents of the first tab"),"Слои");
 tabsheet.addTab(table, "Tab");
 tabsheet.addTab(new Label("Contents of the third tab"),"Межевые планы");

Now i want to add another component to second tab for example a horisontalLayout

  HorizontalLayout lo = new HorizontalLayout();
  Button newContact = new Button();
  Button search = new Button();
  Button share = new Button();
  Button help = new Button();
   lo.addComponent(newContact);
   lo.addComponent(search);
   lo.addComponent(share);
   lo.addComponent(help);

But how to do this?

Upvotes: 2

Views: 5277

Answers (2)

Anatoly
Anatoly

Reputation: 1591

First you should define layout of the whole tab, after that you can add to this layout another components. See example below:

VerticalLayout verticalLayout = new VerticalLayout();
verticalLayout.setSizeFull();
tabsheet.addTab(verticalLayout, "Vertical Layout with inline components");
verticalLayout.addComponent(new Lable("Example"));
verticalLayout.addComponent(new Button("Button"));

Upvotes: 0

Nicolas Modrzyk
Nicolas Modrzyk

Reputation: 14197

Prepare a layout:

    VerticalLayout l1 = new VerticalLayout();
    l1.setMargin(true);
    l1.addComponent(new Label("I am a label."));
    ... add your other components here.

Then add it to your tabsheet:

    TabSheet t = new TabSheet();
    t.setHeight("200px");
    t.setWidth("400px");
    t.addTab(l1, "My Tab", icon1);

Upvotes: 4

Related Questions