GridBagLayout panels alignment

后端 未结 7 1556
北荒
北荒 2020-12-07 01:38

I have a little issue with the GridBag Layout Manager. I am trying to display 9 panels like this:

\"Ideal

7条回答
  •  攒了一身酷
    2020-12-07 02:16

    Generally, I create and add the components of a GridBagLayout in Y, X position order. I don't know if this is required, but it makes it easier for me to diagnose problems.

    Here's what I came up with for your grid.

    Component   xPosition   yPosition   xWidth   yHeight
    ---------   ---------   ---------   ------   -------
    S1              0           0          2        2
    S2              2           0          2        1
    S4              4           0          2        2
    S5              6           0          2        1
    S7              8           0          2        2
    S8              0           2          5        1
    S3              2           2          2        1
    S9              5           2          5        1
    S6              6           2          2        1
    

提交回复
热议问题