Java 在Vaadin中设置GridLayout行高度
非常直截了当的问题,如果在Vaadin中定义了GridLayout,如何设置所有/单个行的高度?例如:Java 在Vaadin中设置GridLayout行高度,java,vaadin,Java,Vaadin,非常直截了当的问题,如果在Vaadin中定义了GridLayout,如何设置所有/单个行的高度?例如: mainLayout = new GridLayout(2, 7); mainLayout.setMargin(true); mainLayout.setWidth("100%"); mainLayout.setHeight("100%"); // Set row[s] height? 提前谢谢 我想请你读这本书 它将解释如何在网格和各行上设置全尺寸,以及各行和列如何具有不同的间距 书中的例
mainLayout = new GridLayout(2, 7);
mainLayout.setMargin(true);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
// Set row[s] height?
提前谢谢 我想请你读这本书 它将解释如何在网格和各行上设置全尺寸,以及各行和列如何具有不同的间距 书中的例子:
GridLayout grid = new GridLayout(3,2);
// Layout containing relatively sized components must have
// a defined size, here is fixed size.
grid.setWidth("600px");
grid.setHeight("200px");
// Add some content
String labels [] = {
"Shrinking column<br/>Shrinking row",
"Expanding column (1:)<br/>Shrinking row",
"Expanding column (5:)<br/>Shrinking row",
"Shrinking column<br/>Expanding row",
"Expanding column (1:)<br/>Expanding row",
"Expanding column (5:)<br/>Expanding row"
};
for (int i=0; i<labels.length; i++) {
Label label = new Label(labels[i], Label.CONTENT_XHTML);
label.setWidth(null); // Set width as undefined
grid.addComponent(label);
}
// Set different expansion ratios for the two columns
grid.setColumnExpandRatio(1, 1);
grid.setColumnExpandRatio(2, 5);
// Set the bottom row to expand
grid.setRowExpandRatio(1, 1);
// Align and size the labels.
for (int col=0; col<grid.getColumns(); col++) {
for (int row=0; row<grid.getRows(); row++) {
Component c = grid.getComponent(col, row);
grid.setComponentAlignment(c, Alignment.TOP_CENTER);
// Make the labels high to illustrate the empty
// horizontal space.
if (col != 0 || row != 0)
c.setHeight("100%");
}
}
GridLayout grid=新的GridLayout(3,2);
//包含相对大小组件的布局必须具有
//定义的大小,这里是固定大小。
网格设置宽度(“600px”);
网格设置高度(“200px”);
//添加一些内容
字符串标签[]={
“收缩列
收缩行”,
“正在扩展列(1:)
正在收缩行”,
“扩展列(5:)
收缩行”,
“收缩列
扩展行”,
“正在扩展列(1:)
正在扩展行”,
“正在扩展列(5:)
正在扩展行”
};
对于(int i=0;iThanks@Marthin),请基本上检查.setRowExpandRatio()方法是的,我想这取决于您要查找的确切结果,但可能这样就可以了!