On Sun, 22 Nov 2020 08:59:48 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

> The problem became visible, when we draw a border across the component using 
> drawLine, and expected that fillRect will clear a border of the component. 
> This is incorrect because in the case of the scaled graphics(retina) some 
> part of the line can be placed outside of the bounds of the rectangle. See 
> additional information here:
> https://bugs.openjdk.java.net/browse/JDK-8011764
> 
> This bug has occurred when the old default metal theme is 
> used(DefaultMetalTheme) or thems based on it(Custom themes in the SwingSet2).
> 
> The fix applies the clip before the rendering so the paint method will not 
> touch pixels outside the component.
> 
> As a fix, we could try to draw the lines using subpixel coordinates, but that 
> code is expected to work using Graphics object(unlike current default metal 
> theme: Ocean)  which uses the only int as a coordinate, not a Graphics2D
> 
> To make rendering a little bit better I tried antialiasing but it does not 
> produce a better result, so did not use it in the fix.

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSliderUI.java line 
1618:

> 1616:             }
> 1617:         }
> 1618:         g.setClip(clip);

Since it is normally seen in Metal L&F, shouldn't we do the clip setting in 
MetalSliderUI.paintThumb() instead?
If we are doing it in BasicSliderUI, can you please explain why are we not 
seeing it in other L&Fs like nimbus or motif?

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

PR: https://git.openjdk.java.net/jdk/pull/1373

Reply via email to