On Wed, 8 Nov 2023 05:06:14 GMT, Prasanta Sadhukhan <[email protected]> wrote:
> Although there seems to be no difference in rendering the scrollbars with and > without these getXXX methods as can be seen here (top one without, bottom one > with the methods), I guess it's expected because `LayoutManager` usually tries to satisfy the preferred size. In this case, each scroll bar gets its preferred size. As soon as you start resizing, the differences become apparent: sizing behaviour is different… because after you remove the overridden `getMinimumSize` and `getMaximumSize` methods, the minimum and maximum sizes of the scroll bar change. > I could see difference in behaviour when the frame is resized and since the > premise of the fix is there should not be any difference in behaviour if > these methods are removed, I agree that removing the methods as is done in > this PR may not be appropriate As soon as you start resizing, the differences become apparent: sizing behaviour is different… because after you remove the overridden `getMinimumSize` and `getMaximumSize` methods, the minimum and maximum sizes of the scroll bar changes. > but I also think adding setXXX methods in JScrollBar class just to clarify > existing spec may also not be appropriate. In this light, can we consider the > previous iteration of the [spec > clarification](https://openjdk.github.io/cr/?repo=jdk&pr=15325&range=03#sdiff-0-src/java.desktop/share/classes/javax/swing/JScrollBar.java) Why not? The previous iteration just adds an additional note to `getXXX` methods — the problem with `setXXX` persists, the methods are inherited from `JComponent` and their specification states, “Subsequent calls to `getMinimumSize` *will always return this value*” [the one passed to `setMinimumSize`], which does not hold. https://github.com/openjdk/jdk/blob/a95062b39a431b4937ab6e9e73de4d2b8ea1ac49/src/java.desktop/share/classes/javax/swing/JComponent.java#L1782-L1784 I propose overriding `setMinimumSize` and `setMaximumSize` and amend their specification to align with the current implementation of `get{Min,Max}Size`. Otherwise, the contract of `set{Min,Max}Size` will still be broken, no matter how many additional warnings we add to their `get-` counterparts. ------------- PR Comment: https://git.openjdk.org/jdk/pull/15325#issuecomment-1804640197
