RFR: 6510914: JScrollBar.getMinimumSize() breaks the contract of JComponent.setMinimumSize() [v2]

Alexey Ivanov aivanov at openjdk.org
Thu Aug 24 19:13:28 UTC 2023


On Thu, 24 Aug 2023 07:46:07 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..
>
> Prasanta Sadhukhan has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - copyright year
>  - Fix maximumSize, test

The comment is below…

`JScrollBar` overrides both `getMinimumSize` and `getMaximumSize` and specifies *different behaviour*: “The scrollbar is flexible along it's scrolling axis and rigid along the other axis.”

Should it follow the rules set by `JComponent`? It don't think so.

How does the scrollbar look like if you set its minimum or maximum size to a larger size along its other axis?

Should we rather update the spec for `JScrollBar`? It may override `setMinimumSize` and `setMaximumSize` to specify different behaviour.

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

PR Review: https://git.openjdk.org/jdk/pull/15325#pullrequestreview-1594280171
Changes requested by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/15325#pullrequestreview-1594282373


More information about the client-libs-dev mailing list