Faile to swap components in HorizontalSplitPanel

Please see the code below, Two buttons in HorizontalSplitPanel are swapped after Button “Swap” is clicked:


		VerticalLayout layout = new VerticalLayout();
		layout.setMargin(true);	
		
		final HorizontalSplitPanel split = new HorizontalSplitPanel();
		split.setFirstComponent(new Button("Left"));
		split.setSecondComponent(new Button("Right"));
		
		Button btn = new Button("Swap");
		btn.addClickListener(new ClickListener() {

			@Override
			public void buttonClick(ClickEvent event) {
				Component c1 = split.getFirstComponent();
				Component c2 = split.getSecondComponent();
				
				if (c1 != null) {
					split.removeComponent(c1);
				}
				
				if (c2 != null) {
					split.removeComponent(c2);
				}
				
				split.setFirstComponent(c2);
				split.setSecondComponent(c1);
								
			}
			
		});
		
		layout.addComponent(split);
		layout.addComponent(btn);
  1. If setFirstComponent is commented, HorizontalSplitPanel doesn’t display;
  2. If setSecondComponent is commented, Button “Left” cannot be swapped into right side.

I wonder whether I miss anything important, or it is a bug.

Hi!
I have a similar problem for a VerticalLayout object. Removing a single component failed - removing component woks, but the rest of layout is not ok. Workaround: verticalLayout.removeAllComponents() and rebuild the layout.

Seems to be a bug!

I created a ticket @ http://dev.vaadin.com/ticket/11920