I’m trying to set a component like a TabSheet at height 100% by using method setHeight but it doesn’t work.
I also try to create my own CSS with the following code to initialize html and body but I’ve got the same result.
If I set height with “px” size there is no problem but obviously I need to get the client window size to adapt the component to the screen.
My question :
is there a way to set component’s height with % in IT Mill ?
Hi, the
setHeight() method allows percentual units.
// Set the tabsheet to scale to full size inside its container
tabsheet.setWidth(100, Sizeable.UNITS_PERCENTAGE);
tabsheet.setHeight(100, Sizeable.UNITS_PERCENTAGE);
Alternatively, you can use
setSizeFull() to easily set both width and height to 100%.
Also remember that setting the size of a component to 100% applies only
inside its containing component . Many layouts tend to shrink to minimum size (horizontally or vertically or both) by default. So, unless the component is the root layout of the window itself, you have to set the size of all the containing layouts and components to 100% as well.
Your Window is generated with default layout (I guess Vertical OrderedLayout), and it’s height is “as small as possible”.
Adding main.getLayout().setHeight(“100%”) helps.
I am working on a first app with Vaadin and setting the height to 100% looks to be quite a challenge.
I run into many forum posts, and I noticed the: [quote]
main.getLayout().setHeight(“100%”)
[/quote]
Apparently it looks like the getLayout method is depreciated on Window Object (running Vaadin 6.5.0). Any reason?
getLayout() was deprecated in favor of getContent(). It does the same thing, but doesn’t expect the returned component to be a layout, just a ComponentContainer.
So main.getContent().setHeight(“100%”); is the current thing to do.