On Mon, 6 Nov 2023 06:22:33 GMT, Prasanta Sadhukhan <psadhuk...@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

> > 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 ?
> 
> One example of consequence of removing the methods is as Alexey pointed out 
> `the scrollbar becomes flexible along its secondary axis too` so `second 
> scrollbar starts growing only after the the third one reaches its minimum 
> size`....Not sure if it will considered a bug if we remove the methods but 
> it's a departure from existing behaviour... That is running Alexey's 
> testcase, if we start to shrink the Frame horizontally, then the 3rd (from 
> left) vertical scrollbar starts to shrink but after a certain point, the 2nd 
> vertical scrollbar starts growing as can be seen on **left side (without 
> methods)** whereas it should remain fixed, as can be seen on **right side 
> (with methods)** 
> ![scroll-resize-shrink](https://user-images.githubusercontent.com/43534309/283344574-290e5603-7d8e-4d14-b2d6-6b7721da86bd.png)

In short:

* the scroll bars are currently **rigid** along their secondary axis, they stay 
at their preferred size. Their widths (referring to Prasanta's case discussing 
the vertical scroll bars) are never less than their preferred size which is 
equal to the minimum and maximum size.  
Thus, the left panel with the vertical scroll bars gets clipped if the frame 
becomes too small, it's clearly seen on the right image above: the right cyan 
border isn't seen any more.
* with the removed `getMinimumSize` and `getMaximumSize` implementation, the 
scroll bars become **flexible** along their secondary axis. What we see is 
natural:
    * The layout manager gives components the preferred size, therefore the two 
scroll bars on the left remain at their preferred size, and the third vertical 
scroll bar shrinks as the frame width shrinks.
    * Once the third vertical scroll bar reaches its minimum size, it can't 
shrink any more, therefore the layout manager makes the second scroll bar 
larger, it can do so because its maximum size is larger than its preferred size.
        * The second scroll bar grows until it reaches its maximum width. After 
this point, the layout manager cannot satisfy the minimum widths of all the 
scroll bars, and the left panel becomes clipped, the part of the third scroll 
bar disappears.

All the above is the result of differences in the returned minimum and maximum 
sizes: *rigid* versus *flexible*.

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

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

Reply via email to