Vaadin布局 - 如何让面板扩展以填充大部分屏幕

时间:2012-05-31 12:30:33

标签: java layout vaadin

请注意我正在使用Vaadin。

我正在努力让中间面板扩展以填充大部分屏幕,顶部和底部分别有页眉和页脚。这是我的代码:

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);
}
}

我哪里错了?我看到的是:

Valid XHTML

1 个答案:

答案 0 :(得分:4)

尝试制作mainColumn.setSizeFull()mainWindow.setContent(mainColumn)