RFR: 8089009: TableView with CONSTRAINED_RESIZE_POLICY incorrectly displays a horizontal scroll bar.
Sai Pradeep Dandem
duke at openjdk.org
Tue Jul 26 23:03:21 UTC 2022
On Tue, 26 Jul 2022 15:40:20 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> @andy-goryachev-oracle Below are my comments for the points you raised:
>> 1. I agree with this and upon inspecting the current code, I noticed that this was already considered for some other bounds checking within the same method `TableUtil.java` -> `constrainedResize(...)`.
>>
>> // Check for zero. This happens when the distribution of the delta
>> // finishes early due to a series of "fixed" entries at the end.
>> // In this case, lowerBound == upperBound, for all subsequent terms.
>> double newSize;
>> if (Math.abs(totalLowerBound - totalUpperBound) < .0000001) {
>> newSize = lowerBound;
>> } else {
>> double f = (target - totalLowerBound) / (totalUpperBound - totalLowerBound);
>> newSize = Math.round(lowerBound + f * (upperBound - lowerBound));
>> }
>>
>> Will it be ok if I create a variable named `double EPSILON=.0000001` and use this in both the places?
>>
>> 2. 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.
>>
>> For reference, there is already an existing JDK ticket [JDK-8089280](https://bugs.openjdk.org/browse/JDK-8089280) and a bit of discussion over this.
>
>> 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.
@andy-goryachev-oracle Thanks for providing the info about constrained resize policy in Swing. Unfornately I didn't get a chance to work with Swing, so I am not fully aware of this functionality that existed in Swing. At this stage in JavaFX,the need with scroll bar visibility comes into picture when working with resizable windows. May be as mentioned in one of the comments in [JDK-8089280](https://bugs.openjdk.org/browse/JDK-8089280), when constrained resize policy is set, it needs to set/override the minWidth of the table view to total minWidths of all columns. And as you said, this might be beyond the scope of this PR.
-------------
PR: https://git.openjdk.org/jfx/pull/848
More information about the openjfx-dev
mailing list