[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: RFR: 6510914: JScrollBar.getMinimumSize() breaks the contract of JComponent.setMinimumSize() [v6
From:       Alexey Ivanov <aivanov () openjdk ! org>
Date:       2023-12-20 17:02:01
Message-ID: PcvQL80fceyCb4mWWqLIYStSE_xIwH6pGlhNI6J_CrU=.1319f9b1-c4e2-44b5-b619-a495ed11fb78 () github ! com
[Download RAW message or body]

On Mon, 20 Nov 2023 12:54:25 GMT, Alexey Ivanov <aivanov@openjdk.org> wrote:

> > > But I do have another suggestion that actually might have been the best thing \
> > > to do all those years ago. Keep the over-ride as the default behaviour, and \
> > > document it better. But if the app calls setMaximumSize or setMinimumSize() \
> > > then honour it like you are supposed to. I suspect very few apps actually call \
> > > these since they are complete no-ops today. If we do that, then yes, you'll \
> > > still see differences if you do call those APIs and forgot about it because it \
> > > didn't make a difference.
> > 
> > 
> > Do you mean this way \
> > https://openjdk.github.io/cr/?repo=jdk&pr=15325&range=01#sdiff-0-src/java.desktop/share/classes/javax/swing/JScrollBar.java \
> > what I had done in the initial iteration? I guess that change will still show the \
> > above problem during frame resize, where scrollbars are not rigid
> 
> This is how I understand Phil's comment.

As I understand Phil's comment, he suggests using the implementation that you used in \
the first iteration of this fix:

https://github.com/openjdk/jdk/blob/31bbdee8ea71f43eb4863af50b398170a7b81ed2/src/java.desktop/share/classes/javax/swing/JScrollBar.java#L762-L772


That is we preserve the current behaviour of `getMinimumSize()` and \
`getMaximumSize()` methods in `JScrollBar`, yet if `setMinimumSize()` or \
`setMaximumSize()` is called, the corresponding `get-` methods return the set value \
and thus they follow the contract specified in `JComponent`.

@prrace, could you confirm, please?

> > I guess that change will still show the above problem during frame resize, where \
> > scrollbars are not rigid
> 
> Yes, it will, this is why update to the javadoc of `getMinimumSize` and \
> `getMaximumSize` is required—to document their default behaviour and the fallback \
> to returning the set sizes as per `JComponent` specification of `setMinimumSize` \
> and `setMaximumSize`.

Maybe, overriding `setMinimumSize` and `setMaximumSize` isn't needed if we respect \
the `JComponent` contract. However, the specification of `getMinimumSize` and \
`getMaximumSize` needs updating to clarify what is returned.

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

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic