You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DelayedColumnLayouting.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.UI;
  5. import com.vaadin.ui.VerticalLayout;
  6. import com.vaadin.v7.ui.Table;
  7. /**
  8. * For tables that are contained in a layout, a delayed column layouting should
  9. * not be visible (because it makes the column jump around).
  10. *
  11. * #15189
  12. *
  13. * @author Vaadin Ltd
  14. */
  15. public class DelayedColumnLayouting extends UI {
  16. @Override
  17. protected void init(VaadinRequest request) {
  18. VerticalLayout verticalLayout = new VerticalLayout();
  19. verticalLayout.setSizeFull();
  20. final VerticalLayout layout = new VerticalLayout();
  21. layout.setSizeFull();
  22. layout.setSpacing(true);
  23. Button reset = new Button("Recreate layout with contained table");
  24. verticalLayout.addComponent(reset);
  25. reset.addClickListener(event -> fillLayout(layout));
  26. fillLayout(layout);
  27. verticalLayout.addComponent(layout);
  28. verticalLayout.setExpandRatio(layout, 1f);
  29. setContent(verticalLayout);
  30. }
  31. private void fillLayout(VerticalLayout layout) {
  32. layout.removeAllComponents();
  33. Table table = new Table();
  34. table.setSizeFull();
  35. table.addContainerProperty("First", String.class, "");
  36. table.addContainerProperty("This column jumps", String.class, "");
  37. layout.addComponent(table);
  38. layout.setExpandRatio(table, 1f);
  39. }
  40. }