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.

InsertComponentInHorizontalLayout.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package com.vaadin.tests.components.orderedlayout;
  2. import com.vaadin.server.VaadinRequest;
  3. import com.vaadin.tests.components.AbstractReindeerTestUI;
  4. import com.vaadin.ui.Button;
  5. import com.vaadin.ui.ComboBox;
  6. import com.vaadin.ui.Component;
  7. import com.vaadin.ui.HorizontalLayout;
  8. import com.vaadin.ui.VerticalLayout;
  9. public class InsertComponentInHorizontalLayout extends AbstractReindeerTestUI {
  10. private VerticalLayout layout;
  11. int added = 1;
  12. private Component getTestLayout() {
  13. ComboBox a = new ComboBox("initial");
  14. Button b = new Button("x", event -> layout.markAsDirty());
  15. final HorizontalLayout hl = new HorizontalLayout(a, b);
  16. hl.setSpacing(true);
  17. Button add = new Button(
  18. "Insert 2 comboboxes between combobox(es) and button 'x'");
  19. add.addClickListener(event -> {
  20. hl.addComponent(new ComboBox("Added " + added++), 1);
  21. hl.addComponent(new ComboBox("Added " + added++), 2);
  22. });
  23. layout = new VerticalLayout(hl, add);
  24. return layout;
  25. }
  26. @Override
  27. protected void setup(VaadinRequest request) {
  28. setContent(getTestLayout());
  29. }
  30. @Override
  31. protected String getTestDescription() {
  32. return "Click the button to add two comboboxes between the existing combobox(es) and the 'x' button";
  33. }
  34. @Override
  35. protected Integer getTicketNumber() {
  36. return 10154;
  37. }
  38. }