java GridLayout 的参数是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/360877/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 12:05:14  来源:igfitidea点击:

What are the parameters for a GridLayout?

javalayoutgrid-layout

提问by Brian Knoblauch

private static final GridLayout layout = new GridLayout( 3, 1, 1, 0 );

in this line of code what do the numbers represent and how do you use them to arrange the checkboxes and buttons in the window?

在这行代码中,数字代表什么以及如何使用它们来排列窗口中的复选框和按钮?

回答by Joe Liversedge

The GridLayoutclass:

网格布局类:

public GridLayout(int rows,
                  int cols,
                  int hgap,
                  int vgap)

Creates a grid layout with the specified number of rows and columns. All components in the layout are given equal size.
In addition, the horizontal and vertical gaps are set to the specified values. Horizontal gaps are placed between each of the columns. Vertical gaps are placed between each of the rows.

One, but not both, of rows and cols can be zero, which means that any number of objects can be placed in a row or in a column.

All GridLayout constructors defer to this one.

Parameters:
rows - the rows, with the value zero meaning any number of rows
cols - the columns, with the value zero meaning any number of columns
hgap - the horizontal gap
vgap - the vertical gap