<Swing Dev> Review request for 4473075: JTable header rendering problem (after setting preferred size)

Semyon Sadetsky semyon.sadetsky at oracle.com
Tue Mar 3 12:30:12 UTC 2015


http://cr.openjdk.java.net/~alexsch/semyon-sadetsky/4473075/webrev.02/

null check is not needed because isPreferredSizeSet() is true only if 
preferred size is not null.
Others are accepted.


On 3/3/2015 1:09 PM, Alexander Scherbatiy wrote:
>
>   The fix looks good to me.
>
>   Just few comments:
>   - Check that getPreferredSize() can't return null if prefferd size 
> is set
>   - extra empty lines 442 and 463 are unnecessary
>   - scpScroll.getHorizontalScrollBar() call (line 69) in the test is 
> called on the main thread. It should be called on EDT.
>
>  Thanks,
>  Alexandr.
>
> On 3/2/2015 4:11 PM, Semyon Sadetsky wrote:
>> Regression test scenario was added. Please review the fix.
>>
>> webrev: 
>> http://cr.openjdk.java.net/~alexsch/semyon-sadetsky/4473075/webrev.01/
>>
>> 2Sergey:
>> the garbage mentioned comments in the JBS is not reproducible 
>> anymore. In any case it is another problem than the described in the 
>> bug header. The fix solves the original issue.
>>
>>
>> On 2/27/2015 4:47 PM, Semyon Sadetsky wrote:
>>> Hi Sergey,
>>>
>>> It really depends on a point of view.
>>> There is a comment in the ViewportLayout.java that states that it is 
>>> an expected behaviour:
>>> /* If the new viewport size would leave empty space to the
>>>   * right of the view, right justify the view or left justify
>>>   * the view when the width of the view is smaller than the
>>>   * container.
>>>   */
>>> ==
>>> Semyon
>>>
>>> On 2/27/2015 4:06 PM, Sergey Bylokhov wrote:
>>>> Hi, Semyon.
>>>> Can you clarify the comment below from the CR. Is the actual bug in 
>>>> JTableHeader and not in JScrollPane? Especially consider, that the 
>>>> behavior changes by different modes of a JScrollPane.
>>>>
>>>> "This problem isn't unique to JTableHeader. For example, consider 
>>>> the test case I've attached, Bug2.java. Run it the same way, 
>>>> resized so that the label header component shows "..." at the end, 
>>>> and then scroll.
>>>>
>>>> This appears to be a problem with how JScrollPane treats any header 
>>>> component with a fixed size like this. There are two things here:
>>>>
>>>> First, I don't understand why garbage is allowed to show up. We at 
>>>> least need to fix this. Second, perhaps JScrollPane needs to do 
>>>> better to ensure that the header is large enough to match the 
>>>> scrollable content."
>>>>
>>>>
>>>> Also I think it is possible to write a test for this issue.
>>>>
>>>> -----semyon.sadetsky at oracle.com  wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> please review a fix for JDK 9.
>>>>>
>>>>> Bug:https://bugs.openjdk.java.net/browse/JDK-4473075
>>>>> Webrev:
>>>>> http://cr.openjdk.java.net/~alexsch/semyon-sadetsky/4473075/webrev.00/ 
>>>>>
>>>>>
>>>>> The thing is the general logic of the viewport layout requires the
>>>>> right
>>>>> component size which is requested by the getPreferredSize call to the
>>>>>
>>>>> child component.
>>>>> The right width of JTableHeader should be calculated in its UI but if
>>>>>
>>>>> user sets the preferred size manually it makes the calculated size
>>>>> invisible outside the component. User may need to set preferred size
>>>>> in
>>>>> order to adjust header height but in setPreferredSize(Dimension) the
>>>>> header width is adjusted as well.
>>>>> The fix solution overrides JComponent::getPreferredSize in
>>>>> JTableHeader
>>>>> with the logic returning the right width while preserving the height
>>>>> adjustable for user.
>>>
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20150303/39f9de32/attachment.html>


More information about the swing-dev mailing list