how to use expand ratio properly

I have the following code for a simple layout of a Window contents:

[code]
Layout left = getLayout1();
left.setSizeFull();
horizontalLayout.addComponent(left);
horizontalLayout.setComponentAlignment(left,Alignment.TOP_RIGHT);
Layout middle = getLayout2();
middle.setSizeFull();
horizontalLayout.addComponent(middle);
horizontalLayout.setComponentAlignment(middle,Alignment.MIDDLE_CENTER);
Layout right = getLayout3();
right.setSizeFull();
horizontalLayout.addComponent(right);
horizontalLayout.setComponentAlignment(right,Alignment.TOP_RIGHT);

    horizontalLayout.setExpandRatio(left,2);
    horizontalLayout.setExpandRatio(middle,6);
    horizontalLayout.setExpandRatio(right,2);

[/code]
getLayout1, getLayout2
and
getLayout3
are Vertical/Horizontal layouts with some components inside them. I do not set any sizes in any of the nested components. However I do seem to get what I thought would be the result, which is
left
and
right
being 1/3 of the size of
middle
. Instead it looks like all components are left-aligned, with lots of space on the right of
right
.

I have set some styles here and there, but I don’t think that should affect anything.

Have I misunderstood how this works? What I require is for
middle
to be space-greedy. I tried setting expand ratio for just
middle
, but that didn’t help.

Thanks in advance.

The horizontal layout seems to be missing a defined size. In that case, there’s nothing that determines its size. Call setSizeFull on it?

Ah yes that was it, thanks