Grid layout problem

Hi,
I want to construct a kind of portal framework in pure Vaadin. I use the gridlayout in order to place the portlets (kind of panel) inside a window. I can reorder my display at will. I use the grid to create a display of 4 columns to 2 rows and decide that from the portal point of view, it only have 2 columns : the first of size 1 column (grid) and the second of size 3 columns (grid) :


||_______|

|P2|_____P3|

If I switch P3 with P2 one time, it works well, but if I try to switch one more time, I obtain the following display :


| |_______________|

| P3|__P2|

P3’s column becomes smaller and smaller at each following switch…

Here is the code for this particular problem :

package com.example.testgridlayout;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;

public class TestgridlayoutApplication extends Application {

private Panel panel1;
private Panel panel2;
private Panel panel3;
private GridLayout grid;


@Override
public void init() {
	Window mainWindow = new Window("Testgridlayout Application");
	VerticalLayout structure = new VerticalLayout();
	structure.setWidth("100%");
	structure.setHeight("100%");
	structure.setMargin(true);
	structure.setCaption("Test GridLayout");
	Button switchBtn = new Button("switch Pane 2 and 3"); 
	
	switchBtn.addListener(new ClickListener(){

		@Override
		public void buttonClick(ClickEvent event) {
			doSwitchPane();
			
		}
		
	});
	structure.addComponent(switchBtn);
	buildGrid();
	structure.addComponent(grid);
	mainWindow.addComponent(structure);
	
	
	setMainWindow(mainWindow);
}

GridLayout buildGrid(){
	grid = new GridLayout(4,2);
	grid.setWidth("100%");
	grid.setHeight("100%");
	panel1 = new Panel("Pane 1");
	panel1.setSizeFull();
	grid.addComponent(panel1, 0,0,3,0);
	panel2 = new Panel("Pane 2");
	panel2.setSizeFull();
	grid.addComponent(panel2, 0,1);
	panel3 = new Panel("Pane 3");
	panel3.setSizeFull();
	grid.addComponent(panel3, 1,1,3,1);
	return grid;
}
public void doSwitchPane(){
	grid.removeComponent(panel2);
	grid.removeComponent(panel3);
	grid.addComponent(panel3, 0,1);
	grid.addComponent(panel2, 1,1,3,1);
}

}

In fact, as you can see, after the first switch, i only remove the components and add them at the same place.
It’s not here a real switch but that does not explain the behaviour displayed.

Any idea if I have done something wrong ?

Thanks

have the same problem. when i remove and add the component, the location of the component slides more and more to the left…

I remember seen such behavior with GridLayout as well. Could you write a ticket about it in our Trac, so the RnD team can have a good look at it?