e633. setting gap sizes in a gridbadlayout.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 17 行

TXT
17
字号
Unlike most of the other layout managers, the gridbag layout manager does not have a property for controlling the size of the gaps between cells. You could implement gaps using insets (see e630 Setting the Space around a Component Within the Cell of the GridBagLayout Using Insets. However, this method is tedious and any change in the layout requires major changes with the insets. 
The next best method is to create a blank column or row explicitly for the desired gaps. 

    // Assume components have been added in cells
    // (0,0), (0,2), (2,0), (2,2)
    
    // Create a 10 pixel gap between columns 0 and 2
    setColumnMinWidth(gbl, 1, 10);
    
    // Create a 10 pixel gap between rows 0 and 2
    setRowMinHeight(gbl, 1, 10);
    
    // setColumnMinWidth() and setRowMinHeight() are defined in
    // e632 Setting a Row or Column of a GridBadLayout to a Particular Size


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?