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

Semyon Sadetsky semyon.sadetsky at oracle.com
Fri Feb 27 13:47:40 UTC 2015


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/20150227/a7f3edc0/attachment.html>


More information about the swing-dev mailing list