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

Phil Race prr at openjdk.org
Thu Jan 18 21:49:52 UTC 2024


On Wed, 3 Jan 2024 05:33:04 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:
> 
>   Honour max/min size if set by user

src/java.desktop/share/classes/javax/swing/JScrollBar.java line 763:

> 761:      * that subsequent calls to getMinimumSize will return the
> 762:      * same value as set in {@code JComponent.setMinimumSize}
> 763:      */

You should add @param

src/java.desktop/share/classes/javax/swing/JScrollBar.java line 776:

> 774:      * same value as set in {@code JComponent.setMaximumSize}
> 775:      */
> 776:     public void setMaximumSize(Dimension maximumSize) {

same here

src/java.desktop/share/classes/javax/swing/JScrollBar.java line 784:

> 782:      * rigid along the other axis.
> 783:      */
> 784:     public Dimension getMinimumSize() {

Since we are here, you should fix this to add the @return. This does not need to be part of the CSR

src/java.desktop/share/classes/javax/swing/JScrollBar.java line 800:

> 798:      * rigid along the other axis.
> 799:      */
> 800:     public Dimension getMaximumSize() {

Since we are here, you should fix this to add the @return. This does not need to be part of the CSR

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

PR Review Comment: https://git.openjdk.org/jdk/pull/15325#discussion_r1458009696
PR Review Comment: https://git.openjdk.org/jdk/pull/15325#discussion_r1458009898
PR Review Comment: https://git.openjdk.org/jdk/pull/15325#discussion_r1458010423
PR Review Comment: https://git.openjdk.org/jdk/pull/15325#discussion_r1458010508


More information about the client-libs-dev mailing list