📄 e632. setting a row or column of a gridbadlayout to a particular size.txt
字号:
By default, the width of a column in a gridbag layout is set to the widest component in the component. This example demonstrates how to increase the width of the column to a particular size. The same applies to rows of a gridbag layout.
See e622 Creating a GridBagLayout for an example on how to use a gridbag layout.
// Sets the minimum width for column c to be w pixels wide
public void setColumnMinWidth(GridBagLayout gbl, int c, int w) {
int[] ws = gbl.columnWidths;
if (ws == null) {
ws = new int[c+1];
} else if (ws.length < c+1) {
ws = new int[c+1];
System.arraycopy(gbl.columnWidths, 0, ws, 0, gbl.columnWidths.length);
}
ws[c] = w;
gbl.columnWidths = ws;
}
// Sets the minimum height for row r to be h pixels high
public void setRowMinHeight(GridBagLayout gbl, int r, int h) {
int[] hs = gbl.rowHeights;
if (hs == null) {
hs = new int[r+1];
} else if (hs.length < r+1) {
hs = new int[r+1];
System.arraycopy(gbl.rowHeights, 0, hs, 0, gbl.rowHeights.length);
}
hs[r] = h;
gbl.rowHeights = hs;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -