Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8313709

Wrong layout of a FlowPane in a BorderPane in a ScrollPane, if padding is too big

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx11, 8, jfx21
    • javafx
    • None

      If we have a scene with a ScrollPane root, which has a BorderPane as content, which has a FlowPane as center node, if the padding of the BorderPane is not set, the layout is correct no matter the space available for the FlowPane children: these are arranged properly.

      However, when the padding is set, and there is not enough space for the FlowPane arrangement that would be determined _without padding_, the layout of the FlowPane is wrong, scrolling doesn't work properly (first and last nodes can't be reached), and only after a manual resize of the stage is applied, the layout is fixed, and scrolling works fine.

      The attached test reproduces the issue.

      If we have 830px total width:

      - ScrollPane: w: 830px, padding: 1 (by default), available w: 828px, with vertical scrollbar: 14.5px, total available: 813.5 px.

      Without padding:
      - BorderPane: 813.5px, padding 0px: total available: 813.5 px.
      - FlowPane: 813.5px, which is greater than 2 textAreas (400) + hgap (10) = 810px, so that fits in, and flowPane puts 2x2 textAreas.

      With padding 1px (see padding1works.png):
      - BorderPane: 813.5px, padding 1px: total available: 811.5 px.
      - FlowPane: 811.5px, which is greater than 2 textAreas (400) + hgap (10) = 810px, so that fits in, and flowPane puts 2x2 textAreas, as expected.

      Running with padding 2px fails:
      - BorderPane: 813.5px, padding 2px: total available: 809.5 px.
      - FlowPane: 809.5px, which is lower than 2 textAreas (400) + hgap (10) = 810px, so that doesn't fit in, and flowPane puts 4x1 textAreas, as expected. However, the layout is wrong, the first and fourth textArea nodes are not visible, and we can't scroll to either of them (see padding2fails.png). For some reason, the BorderPane layout still corresponds to a 2x2 FlowPane.

      Only after a small resizing of the stage, layout gets fixed (see padding2fixed.png), and scrolling works fine.

      This issue can be reproduced with any JavaFX version.

        1. padding1works.png
          padding1works.png
          420 kB
        2. padding2fails.png
          padding2fails.png
          416 kB
        3. padding2fixed.png
          padding2fixed.png
          414 kB
        4. ScrollPaneTest.java
          1 kB

            jpereda Jose Pereda
            jpereda Jose Pereda
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: