RFR: 6510914: JScrollBar.getMinimumSize() breaks the contract of JComponent.setMinimumSize()
Alexey Ivanov
aivanov at openjdk.org
Thu Aug 17 15:26:31 UTC 2023
On Thu, 17 Aug 2023 08:42:13 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> javadoc contract for JComponent.setMinimumSize(Dimension) states:
>
> "Sets the minimum size of this component to a constant value. Subsequent calls to getMinimumSize will always return this value..."
>
> However, JScrollBar overrides getMinimumSize() and breaks this contract - it always returns a minimum size derived from the preferred size even if you have previously called setMinimumSize()
>
> Fix is made to check if mnimumSize is set and if so, honour it..
Looks good to me.
Could you update the copyright year in `JScrollBar.java`?
test/jdk/javax/swing/JScrollBar/JScrollBarMinSizeTest.java line 43:
> 41: bar.setMinimumSize(new Dimension(75, 0));
> 42: dim = bar.getMinimumSize();
> 43: });
In this case, it is safe to call these methods on the main thread.
-------------
Marked as reviewed by aivanov (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15325#pullrequestreview-1582878132
PR Review Comment: https://git.openjdk.org/jdk/pull/15325#discussion_r1297381245
More information about the client-libs-dev
mailing list