RFR: 8089009: TableView with CONSTRAINED_RESIZE_POLICY incorrectly displays a horizontal scroll bar.

Andy Goryachev angorya at openjdk.org
Tue Jul 26 15:44:10 UTC 2022


On Tue, 26 Jul 2022 01:02:13 GMT, Sai Pradeep Dandem <duke at openjdk.org> wrote:

> I am not sure about setting TableView.CONSTRAINED_RESIZE_POLICY means to always hide the horizontal scroll bar. The most common use case with the CONSTRAINED_RESIZE_POLICY, is to auto stretch the columns if there is enough space, and set to the minimum widths and show horizontal scroll bar if there is not enough space. I included an example in this stackoverflow [question](https://stackoverflow.com/questions/73060277/horizontal-scrollbar-is-visible-in-tableview-with-constrained-resize-policy) and the gif show-casing the requirement (2nd gif). And the current code already handles this very well.

Quite the opposite.  As an app developer, I've used unrestrained policy (in swing) exactly once, all other cases used fit-to-width.

Even if you look at stackoverflow and even [JDK-8089280](https://bugs.openjdk.org/browse/JDK-8089280) it is clear that the app developers do not want to see the horizontal scroll bar with the constrained policy set, ever.  This was one of the pain points with javafx coming from swing.  

In swing, JTable offers a rich set of possibilities:

`    /** Do not adjust column widths automatically; use a horizontal scrollbar instead. */
    public static final int     AUTO_RESIZE_OFF = 0;

    /** When a column is adjusted in the UI, adjust the next column the opposite way. */
    public static final int     AUTO_RESIZE_NEXT_COLUMN = 1;

    /** During UI adjustment, change subsequent columns to preserve the total width;
      * this is the default behavior. */
    public static final int     AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2;

    /** During all resize operations, apply adjustments to the last column only. */
    public static final int     AUTO_RESIZE_LAST_COLUMN = 3;

    /** During all resize operations, proportionately resize all columns. */
    public static final int     AUTO_RESIZE_ALL_COLUMNS = 4;`

In javafx, behavior of TableView.CONSTRAINED_RESIZE_POLICY is, permit me to say, simply incorrect.  The scope of this discussion may go beyond the scope of this PR, but the fact that we have a number of JDK bugs logged against it is an indication.

-------------

PR: https://git.openjdk.org/jfx/pull/848


More information about the openjfx-dev mailing list