⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e624. getting the number of rows and columns of cells in a gridbaglayout.txt

📁 这里面包含了一百多个JAVA源文件
💻 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 + -