Reputation: 301
Suppose I have a JPanel
with a GridBagLayout
like this:
-----------------------------------------------
| | | | |
| |Left JLabel 1 | Right JLabel 1| |
| | | | |
|-glue-|Left JLabel 2 | Right JLabel 2|-glue-|
| | | | |
| | Bottom JLabel | |
| | | | |
| vertical glue |
-----------------------------------------------
The left/right labels each span 1 row and 1 column, while the bottom label spans 1 row and 2 columns. The horizontal glues on both sides span 3 rows and 1 column each. The vertical glue at the bottom spans 1 row and 4 columns.
Each of the labels has a weighty
of 1.0
. Further, the glues on both sides also have a weighty
of 1.0
. The vertical glue has a weighty
of 1.5
. Currently, when I resize the panel in the y
-direction, the vertical glue gets approximately 3/5ths of the available space and the entire upper portion gets approximately 2/5ths of the available space.
My question is, how does the weighting work when the glue overlaps (when viewed from the y
-resize perspective) with the buttons? Without the glue, the total weight of the buttons would have been 3.0
: this is a completely different resizing scenario! How is the weight actually calculated (highest, average, 'seen from a resize perspective', ?) and used?
Upvotes: 0
Views: 307
Reputation: 324128
Well, the calculation is rather complex so who knows exactly what is happening.
I would guess you are getting something like:
Upvotes: 2