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.

ReplaceComponentNPE.java 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package com.vaadin.tests.components.orderedlayout;
  2. import com.vaadin.tests.components.TestBase;
  3. import com.vaadin.ui.Button;
  4. import com.vaadin.ui.VerticalLayout;
  5. import com.vaadin.ui.Button.ClickEvent;
  6. public class ReplaceComponentNPE extends TestBase {
  7. @Override
  8. protected String getDescription() {
  9. return "Clicking 'ReplaceComponent' should replace the 'Button' button with a VericalLayout, and move the button inside the verticalLayout. Visually this can be seen by the added margins of the VerticalLayout.";
  10. }
  11. @Override
  12. protected Integer getTicketNumber() {
  13. return 3195;
  14. }
  15. final Button button = new Button("Button");
  16. final VerticalLayout outer = new VerticalLayout();
  17. @Override
  18. protected void setup() {
  19. outer.setMargin(true);
  20. Button changer = new Button("ReplaceComponent");
  21. changer.addListener(new Button.ClickListener() {
  22. public void buttonClick(ClickEvent event) {
  23. getLayout().replaceComponent(button, outer);
  24. outer.addComponent(button);
  25. }
  26. });
  27. getLayout().addComponent(button);
  28. getLayout().addComponent(changer);
  29. }
  30. }