?? e624. getting the number of rows and columns of cells in a gridbaglayout.txt
字號:
The number of rows and columns in a GridBagLayout automatically grows as needed when components are added. The current number of rows and columns can be determined by calling getLayoutDimensions(). However, it won't return the correct values until the components have been laid out at least once before the call to getLayoutDimensions(). Unless you can be sure the components have been laid out at least once, you should explicitly call layoutContainer() to force a layout of the components.
GridBagLayout gbl = new GridBagLayout();
container.setLayout(gbl);
// Add components to container and gbl
// Force the layout of components before calling getLayoutDimensions()
gbl.layoutContainer(container);
// Get the dimensions
int[][] dim = gbl.getLayoutDimensions();
int cols = dim[0].length;
int rows = dim[1].length;
Related Examples
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -