RFR: 4797982: Setting negative size of JSplitPane divider leads to unexpected results. [v6]

Karl T duke at openjdk.org
Sat Aug 13 15:20:20 UTC 2022


On Thu, 28 Jul 2022 04:07:55 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> Setting JSplitPane divider size to negative value leads to unexpected results and is not desirable and seems to be not practical.
>> I guess we should return IAE but it might break existing app so fixed to clamp it to 0 incase negative value is tried to be set for divider size.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Remove implNote tag

Hmm, have some concerns with this change.

### Why not allow zero divider size?

The look and feel could use an invisible 6px wide divider that partly overlaps the left and right components.
Then moving divider is still possible, but no divider is visible, which is often used in modern UI.
I actually plan to implement this for [FlatLaf](https://github.com/JFormDesigner/FlatLaf).

Sure, with current L&Fs it is not possible to move divider when dividerSize is zero,
but applications may still control the divider location with `JSplitPane.setDividerLocation()`.
So it is possible that dividerSize zero is used in existing applications.


### Why ignoring negative values?

Wouldn't it better to throw an `IllegalArgumentException` to give the developer some feedback?
Isn't this common practice in Java?
There are several parameter checks in `JSplitPane` and all throw `IllegalArgumentException`.
E.g. `JSplitPane.setResizeWeight(double)`

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

Changes requested by DevCharly at github.com (no known OpenJDK username).

PR: https://git.openjdk.org/jdk/pull/9566



More information about the client-libs-dev mailing list