I found out a solution by myself. It’s stil a hack but it works GREAT.
Why try adding a border if vaadin just doesn’t “like” it? Well, sometimes borders are very nice to have, so let’s draw them differently:
All you need is an image with the dimension [borderWidth]
x[borderWidth]
. (Probably nice to let Java generate it…) and the following css applied to your layout:
Assume we have a
VerticalLayout vLayout = new VerticalLayout();
vLayout.addStyleName("myBorderStyleLayoutName");
vLayout.setSpacing(true); //otherwise the border will be too close to the components added to the vLayout
vLayout.addComponent(myComponent);
...
Finally add the border-hack-style:
.v-verticallayout-myBorderStyleLayoutName{
background-image: url(img/gg/border/3_FFFFFF.png),url(img/gg/border/3_FFFFFF.png),url(img/gg/border/3_FFFFFF.png),url(img/gg/border/3_FFFFFF.png);
background-position: top left, top left, top right, bottom left;
background-repeat: repeat-x, repeat-y,repeat-y,repeat-x;
}
“3_FFFFFF.png” is an image which is all white (#FFFFFF) and has a size of 3x3 pixels.
It is important to know that the “multiple backgrounds” are only supported since CSS 3.0 as far as I know.
Anyway, I tested my vaadin-sizecalculations-friendly border-hack on Chrome, IE9, and latest Firefox (12.0 I guess).
As far as I know all other common browsers should support it, probably versions of IE < 9.0 won’t.
I hope this helps other people not trying to set “border: 3px solid blaaa” for more than two days in vaadin… 
I have added a “rCorner” Style as well, which makes the border edges rounded, even with my hack…
.rCorner{
border-radius:5px;
moz-border-radius:5px;
}
Maybe I forgot something important else than (very old) browsers won’t render correctly (well still sizing will be nice, but no borders, probably users with old-browser can live without them?)
Another idea I’ve just had is to use a GridLayout and put empty but background-colored Labels into the north,south,east and west cell. The real Component will be put in to the center cell. Don’t know if that would work as well…