set rest of height / width for a layout component

Hi,

is there any way to set the height of a component to the rest of screen height?

For example: [code]

	this.cMainWindow = new Window("MoSys Organiza");
	this.cMainWindow.setTheme("MoSysOrganiza");
	
	VerticalLayout cHeader = new VerticalLayout();
	cHeader.setStyleName("PortalHeader");
	cHeader.setHeight("95px");
	cHeader.addComponent(new Label("Header 1"));		
	this.cMainWindow .addComponent(cHeader);
	
	/* would like this one taking the rest of screen height ??? */
	VerticalLayout cBody = new VerticalLayout();
	cBody.setStyleName("PortalBody");
	cBody. ????
	cBody.addComponent(new Label("Body 1"));		
	this.cMainWindow .addComponent(cBody);
	
	HorizontalLayout cFooter = new HorizontalLayout();
	cFooter.setHeight("25px");
	cFooter.setStyleName("PortalFooter");
	cFooter.addComponent(new Label("Footer 1"));
	cFooter.addComponent(new Label("Footer 2"));
	cFooter.addComponent(new Label("Footer 3"));
	this.cMainWindow .addComponent(cFooter);
	
	setMainWindow(this.cMainWindow );

[/code]

I actually got solution by resize event from my other post but actually it does only work as browser loaded and it takes more time as I wanted.

I hope there is another way to solve issue like I mentioned above (See the Code Comment)

Regards
Dirk

Is this what you are looking for ?

        
        this.cMainWindow = new Window("MoSys Organiza");
        this.cMainWindow.setHeight("100%");
        this.cMainWindow.setTheme("MoSysOrganiza");
        VerticalLayout vBody = new VerticalLayout();
        vBody.setSizeFull();
        
        VerticalLayout cHeader = new VerticalLayout();
        cHeader.setStyleName("PortalHeader");
        cHeader.setHeight("95px");
        cHeader.addComponent(new Label("Header 1"));
        vBody.addComponent(cHeader);
        /* would like this one taking the rest of screen height ??? */
        VerticalLayout cBody = new VerticalLayout();        
        cBody.setStyleName("PortalBody");        
        cBody.setHeight("100%");       
        cBody.addComponent(new Label("Body 1"));                
        vBody.addComponent(cBody);    
        vBody.setExpandRatio(cBody, 1);
        HorizontalLayout cFooter = new HorizontalLayout();        
        cFooter.setHeight("25px");        
        cFooter.setStyleName("PortalFooter");        
        cFooter.addComponent(new Label("Footer 1"));
        cFooter.addComponent(new Label("Footer 2"));
        cFooter.addComponent(new Label("Footer 3"));
        vBody.addComponent(cFooter);
        this.cMainWindow.addComponent(vBody);
        this.cMainWindow.setBorder(0);
        this.cMainWindow.getContent().setHeight("100%");
        setMainWindow(this.cMainWindow );

@Arnold: No, your code was not working, got an empty browser after I have tried…

Just comment out the setTheme line and the code from Arnold works, there is something wrong with your theme “MoSysOrganiza”.

//this.cMainWindow.setTheme("MoSysOrganiza");

setExpandRatio gives all “unused” space (100%) in vBody to cBody:

vBody.setExpandRatio(cBody, 1);

well, now its working, just dropping the theme.

My theme did not set any size. How would that code work with a user defined css file?

oh, … forgot to import the vaadin style in my code.
No it is working…

For anyone which got the same issue to solve:

css style in …/WebContent/VAADIN/themes/[StyleName]
/styles.css:

@CHARSET "ISO-8859-1";
@import "../reindeer/styles.css";

body
{
	background: #F00;
	margin: 0px;
	padding: 0px;
}

.PortalsMainWindow
{
	background: #000;
	margin: 0px;
}

.PortalsMainLayout
{
	background: #333;
	margin: 0px;
}

.PortalHeader
{		
	background: #eee;
}

.PortalFooter
{
	background: #ddd;
}

.PortalBody
{
	background: #00F;
}


and the code in the Application:


package com.mosys.organiza.prototype;

import com.vaadin.Application;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;

public class PortalBuilder extends Application 
{
	private static final long serialVersionUID = 1L;
	private Window cMainWindow;
	private VerticalLayout cMainLayout;
	private VerticalLayout cPortalheader;
	private VerticalLayout cPortalBody;
	private HorizontalLayout cPageBottom;	

	@Override
	public void init() 
	{
		this.cMainWindow = new Window("MoSys Organiza");
        this.cMainWindow.setHeight("100%");
        this.cMainWindow.setTheme("MoSysOrganiza");
        this.cMainWindow.setStyleName("PortalsMainWindow");
        this.cMainWindow.setSizeFull();       
        
        this.cMainLayout = new VerticalLayout();
        this.cMainLayout.setSizeFull();
        this.cMainLayout.setStyleName("PortalsMainLayout");
        this.cMainLayout.setMargin(false);
        
        this.cPortalheader = new VerticalLayout();
        this.cPortalheader.setStyleName("PortalHeader");
        this.cPortalheader.setHeight("95px");
        this.cPortalheader.addComponent(new Label("Header 1"));
        this.cPortalheader.setMargin(false);
        this.cMainLayout.addComponent(this.cPortalheader);
        
        this.cPortalBody = new VerticalLayout();       
        this.cPortalBody.setStyleName("PortalBody");       
        this.cPortalBody.setHeight("100%");      
        this.cPortalBody.addComponent(new Label("Body 1"));               
        this.cMainLayout.addComponent(this.cPortalBody);   
        this.cMainLayout.setExpandRatio(this.cPortalBody, 1);
        
        this.cPageBottom = new HorizontalLayout();       
        this.cPageBottom.setHeight("25px");       
        this.cPageBottom.setStyleName("PortalFooter");
        this.cPageBottom.setWidth("100%");
        this.cPageBottom.addComponent(new Label("Footer 1"));
        this.cPageBottom.addComponent(new Label("Footer 2"));
        this.cPageBottom.addComponent(new Label("Footer 3"));
        this.cMainLayout.addComponent(this.cPageBottom);
        
        this.cMainWindow.setContent(this.cMainLayout);
        this.cMainWindow.setBorder(0);
        this.cMainWindow.getContent().setHeight("100%");
        
        setMainWindow(this.cMainWindow );
	}

}

Hope thats the best way to do it…

Thanx to all the repliers!

with best regards
Dirk