ac_
ac_

Reputation: 1167

Vaadin Layout - how to get a panel to expand to fill most of the screen

Please note I'm Using Vaadin for this.

I'm struggling to get the middle panel to expand to fill most of the screen with a header and footer at the top and bottom respectively. Here's my code:

public class GridpocApplication extends Application {

@Override
public void init() {
    System.out.println("starting now.");

    final Window mainWindow = new Window("My Application");
    setMainWindow(mainWindow);

    mainWindow.getContent().setSizeFull();

    VerticalLayout mainColumn = new VerticalLayout();
    //Header
    Label top = new Label("HEADER");
    mainColumn.addComponent(top);

    //The middle bit
    final Panel middlePanel = new Panel();
    middlePanel.setSizeFull();
    middlePanel.getContent().setSizeUndefined();
    middlePanel.setScrollable(true);
    mainColumn.addComponent(middlePanel);
    mainColumn.setExpandRatio(middlePanel, 1.0f);

    //footer
    Label bottom = new Label("FOOTER");
    mainColumn.addComponent(bottom);
    mainWindow.addComponent(mainColumn);

    //test
    Label test= new Label("This area should fill most of the screen.");
    middlePanel.addComponent(test);
}
}

Where am I going wrong? What I see is this:

Valid XHTML

Upvotes: 1

Views: 12683

Answers (1)

Charles Anthony
Charles Anthony

Reputation: 3155

Try making mainColumn.setSizeFull() and mainWindow.setContent(mainColumn)

Upvotes: 4

Related Questions