GridLayout: any way to set styles on "columns"

I have a simple 3 column GridLayout where I’d like the first column to be left justified, the center column centered, and the right column right justified.

Is there any way to set this on the columns (div) created by the GridLayout?

I don’t see any styles on the DIVs created, so I can’t see any way to affect them through styling.

Thanks…

Hi,

Use the for^h^h^h Java,
setComponentAlignment()
in this case:

GridLayout gl = new GridLayout(3, 2);
        gl.setWidth("500px");
        mainWindow.addComponent(gl);

        Button b = new Button("One");
        gl.addComponent(b);
        gl.setComponentAlignment(b, Alignment.MIDDLE_LEFT);

        b = new Button("Two");
        gl.addComponent(b);
        gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER);

        b = new Button("Three");
        gl.addComponent(b);
        gl.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);

        b = new Button("One again");
        gl.addComponent(b);
        gl.setComponentAlignment(b, Alignment.MIDDLE_LEFT);

        b = new Button("Two again");
        gl.addComponent(b);
        gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER);

        b = new Button("Three again");
        gl.addComponent(b);
        gl.setComponentAlignment(b, Alignment.MIDDLE_RIGHT);

Also note that Sampler contains a lot of example code, it might save you some time - in this case
http://demo.vaadin.com/sampler/#LayoutAlignment

Best Regards,
Marc

Rats! Now I feel dumb because I had that code in previously when I was working with a set of nested VerticalLayouts and HorizontalLayouts to effect a grid-like look, so not sure why I didn’t think the same would work with GridLayout. Mea culpa! Thanks for setting me straight…