java Vaadin Layout - 如何让面板展开以填满大部分屏幕
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10833652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Vaadin Layout - how to get a panel to expand to fill most of the screen
提问by ac_
Please note I'm Using Vaadin for this.
请注意,我为此使用了 Vaadin。
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:
我哪里错了?我看到的是这样的:
回答by Charles Anthony
Try making mainColumn.setSizeFull()
and mainWindow.setContent(mainColumn)
尝试制作mainColumn.setSizeFull()
和mainWindow.setContent(mainColumn)