您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TableColumnWidthsAndExpandRatios.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.vaadin.tests.components.table;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.HorizontalLayout;
  4. import com.vaadin.ui.NativeButton;
  5. import com.vaadin.v7.ui.Table;
  6. public class TableColumnWidthsAndExpandRatios extends TestBase {
  7. @Override
  8. protected void setup() {
  9. getLayout().setSizeFull();
  10. final Table table = new Table();
  11. table.setSizeFull();
  12. table.addContainerProperty("column1", String.class, "Humpty");
  13. table.addContainerProperty("column2", String.class, "Dumpty");
  14. table.addContainerProperty("column3", String.class, "Doe");
  15. for (int row = 0; row < 100; row++) {
  16. table.addItem();
  17. }
  18. HorizontalLayout buttons = new HorizontalLayout();
  19. for (Object col : table.getContainerPropertyIds()) {
  20. buttons.addComponent(createResetButton(col, table));
  21. }
  22. addComponent(table);
  23. addComponent(buttons);
  24. }
  25. private NativeButton createResetButton(final Object property,
  26. final Table table) {
  27. return new NativeButton("Reset " + property + " width",
  28. event -> table.setColumnWidth(property, -1));
  29. }
  30. @Override
  31. protected String getDescription() {
  32. return "Changing column width to -1 should remove any previous size measurements";
  33. }
  34. @Override
  35. protected Integer getTicketNumber() {
  36. return 7922;
  37. }
  38. }