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

Tree/TableView unexpectedly shows horizontal scrollbar with custom resize policy and unsnapped column width

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx25
    • javafx
    • None

      Applying a custom resize policy that doesn't extend from ConstrainedColumnResizeBase to a tableView control, that allows showing the horizontal scrollbar when the width of the stage is lower than the minimum width of the tableView (as sum of the minimum width of its visible columns), would resize the columns width when the stage gets resized, but it shouldn't show the scrollbar when the width of the stage is bigger.

      When the column width is not properly snapped, the horizontal scrollbar shows up unexpectedly, flickering (showing up and hiding repeatedly) as the stage gets resized. This can be reproduced on macOS and Windows, under any screen render scale.

      When the column width is snapped (with either Math.ceil, Math.floor, TableView::snapSizeX, TableView::snapSpaceX or TableView::snapPositionX), the horizontal scrollbar doesn't show up anymore on macOS (render scale 2.0) or Windows (render scale 1.0 or 2.0), but keeps showing up with fractional scales on Windows (1.25, 1.50, 1.75).

      The workaround for fractional scales found so far is to use an adapted version of the private Region::snapPortionX, that uses ScaledMath::floor instead of the other snap public methods that use round or ceil.

      To reproduce the issue, run the attached test case with any recent JavaFX version (after 25-ea+7, to include the recent fix for JDK-8299753), on macOS or Windows.

      Start resizing the stage, enlarging it, and see how the horizontal scrollbar shows up ("TableView with ScrollBar.png") and hides ("TableView without ScrollBar.png").

      Then change TEST_OPTION from 0 to any of 1 to 6 values. Running on macOS or Windows with render scales 1.0 and 2.0 will work (no scrollbar shown when stage width is bigger than minimum table width), and it will still fail on Windows with fractional scales 1.25, 1.50 or 1.75.

      Finally, set TEST_OPTION to 7, and it will work on all platforms with any render scale.

        1. TableViewResizeTest.java
          6 kB
          Jose Pereda
        2. TableView without ScrollBar.png
          267 kB
          Jose Pereda
        3. TableView with ScrollBar.png
          258 kB
          Jose Pereda

            angorya Andy Goryachev
            jpereda Jose Pereda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: