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

Phil Race prr at openjdk.org
Wed Nov 15 23:36:34 UTC 2023


On Mon, 6 Nov 2023 06:22:33 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 one additional commit since the last revision:
> 
>   Reinstate setEnabled

Alexey has a point. Currently the set* methods are complete no-ops, so that needs to be considered here.

This is an example of what can happen if method A specifies what method B will do :-)
Admittedly these cases are tightly coupled.

About Alexey's example,
I can't figure out what I'm supposed to be learning from the images in the bug report.
Can someone attach somewhere a clear "with methods" vs "without methods" (ie before and after, side-by side screenshot) of what is considered to be the most problematic consequence of removing them ?

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

PR Comment: https://git.openjdk.org/jdk/pull/15325#issuecomment-1813459830


More information about the client-libs-dev mailing list