title: Can replace Vaadin layout component inside Panel?
body: <p>Am using Vaadin 7.3.10.</p>
  
  <p>I have added a layout component inside a panel in order that
  the layouts shall be scrolled if required.</p>
  
  <p>However when I try to replace the layout component, the new 
  component adds to (is shown below) rather than replaces the
  existing component - see below for code sample.</p>
  
  <p>How/Can this be done?</p>
  
  <p>n.b. if the layout is not contained inside the panel, the
  replacement occurs correctly.
  Also, I do not require to use the Navigator for this.</p>
  
  <p>Thank you,
  Steve...</p>
  
  <pre><code>import com.vaadin.ui.Button;
  import com.vaadin.ui.Label;
  import com.vaadin.ui.Panel;
  import com.vaadin.ui.VerticalLayout;
  import com.vaadin.ui.Button.ClickEvent;
  
  public class NewComponent extends VerticalLayout {
  
  private VerticalLayout mainLayout = new VerticalLayout();
  private Panel panel = new Panel();
  
  public NewComponent() {
  
      mainLayout.addComponent(new Label("Main"));
      mainLayout.setSizeFull();       
      addComponent(mainLayout);
  
      panel.setWidth("1000px");
      panel.setHeight("500px");       
      panel.setContent(mainLayout);
  
      Button button = new Button("Click Me");
      button.addClickListener(new Button.ClickListener() {
          public void buttonClick(ClickEvent event) {
              replaceComponent(mainLayout,  new Label("what's wrong?"));
          }
      });
  
      mainLayout.addComponent(button);    
      addComponent(panel);            
  }
  }
  
  public class TestUI extends UI {
  
  @WebServlet(value = "/*", asyncSupported = true)
  @VaadinServletConfiguration(productionMode = false, ui = TestUI.class)
  public static class Servlet extends VaadinServlet {
  }
  
  @Override
  protected void init(VaadinRequest request) {
      setContent(new NewComponent());
  }
  </code></pre>