RFR: 8092379: GridPane should not render extra gaps when entire rows or columns are unmanaged [v2]
John Hendrikx
jhendrikx at openjdk.org
Sat Nov 29 16:17:37 UTC 2025
> This fixes a long standing bug with `GridPane` where unmanaged nodes would still result in gaps being added between rows/columns even though nothing is rendered there. Take the following grid where dashes and pipes represent the vgaps and hgaps:
>
> | |0| |1|
> |--------|---|---|---|
> |0 |A|||B|
> | |-|||-|
> |1 |C|||D|
> | |-|||-|
> |2 |E|||F|
>
> Now, when both C and D are set to unmanaged (and invisible) the grid will **still** render the gaps:
>
> | |0| |1|
> |--------|---|---|---|
> |0 |A|||B|
> | |-|||-|
> |1 |||||
> | |-|||-|
> |2 |E|||F|
>
> Instead it should collapse the gap between row 0 and 2:
>
> | |0| |1|
> |--------|---|---|---|
> |0 |A|||B|
> | |-|||-|
> |2 |E|||F|
>
> There are at least two relevant issues in JBS:
> - A request to let the user show and hide rows and columns: https://bugs.openjdk.org/browse/JDK-8136901
> - This can now be done by setting the relevant row/columns items to unmanaged without having to restructure the grid (assuming the complaint was that otherwise there'd be visible extra gaps for each hidden row)
> - A request for another mode to skip gaps when entire rows/columns are unmanaged: https://bugs.openjdk.org/browse/JDK-8092379
> - This should not be a mode, but the standard, as unmanaged nodes should not affect the outcome of the grid layout
>
> Screenshots
>
> Simple application which can hide row 3:
>
> <img width="443" height="491" alt="image" src="https://github.com/user-attachments/assets/0342dba3-cd1c-4d9e-9451-e9c8c628b2e2" />
>
> Correct behavior when row 3 is hidden:
>
> <img width="443" height="408" alt="image" src="https://github.com/user-attachments/assets/c7c54414-6a03-43e4-b733-21d0b251d729" />
>
> Behavior before this fix (note the double gap **and** extra grid line):
>
> <img width="443" height="453" alt="image" src="https://github.com/user-attachments/assets/f357e68a-e950-42e7-890b-91a78e194dd0" />
John Hendrikx has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision:
- Merge branch 'openjdk:master' into feature/grid-proper-gaps
- When all nodes starting in a row or column are unmanaged, skip gap
-------------
Changes:
- all: https://git.openjdk.org/jfx/pull/1990/files
- new: https://git.openjdk.org/jfx/pull/1990/files/8155fc61..9f2f95df
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jfx&pr=1990&range=01
- incr: https://webrevs.openjdk.org/?repo=jfx&pr=1990&range=00-01
Stats: 3630 lines in 126 files changed: 2903 ins; 302 del; 425 mod
Patch: https://git.openjdk.org/jfx/pull/1990.diff
Fetch: git fetch https://git.openjdk.org/jfx.git pull/1990/head:pull/1990
PR: https://git.openjdk.org/jfx/pull/1990
More information about the openjfx-dev
mailing list