RFR: 8187759: Background not refreshed when painting over a transparent JFrame
Abhishek Kumar
abhiscxk at openjdk.org
Fri Jan 12 06:35:26 UTC 2024
On Tue, 12 Dec 2023 13:04:26 GMT, Tejesh R <tr at openjdk.org> wrote:
> This is happening in linux where `BuffereStrategyPaintManager` is used to paint to offscreen. Here `bsg` bufferStrategy SunGraphics2D is used to paint to offscreen where the background is not refreshed, which does only clipping and then paints to offscreen. In order to handle the screen updated/clear the buffer, `setBackground` to component background color and `clearRect` against the clip area is used which solves the issue without causing any regression.
> CI is green for the fix and manual test is provided.
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 89:
> 87: frame.addMouseMotionListener(new MouseDragListener());
> 88: frame.setVisible(true);
> 89:
May not require.
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 90:
> 88: frame.setVisible(true);
> 89:
> 90: }
Blank line before method.
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 101:
> 99: /** Capture an image of any component **/
> 100: private static BufferedImage getImage(Component c) {
> 101: if(c==null) return null;
Suggestion:
if (c == null) {
return null;
}
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 122:
> 120: public TranslucentPane() {
> 121: setOpaque(false);
> 122: }
Blank line after this.
test/jdk/javax/swing/JFrame/JFrameBackgroundRefreshTest.java line 129:
> 127: g2d.setColor(new Color(0,0,0,0));
> 128: g2d.fillRect(0, 0, getWidth(), getHeight());
> 129: g2d.drawImage(test, p.x, p.y, this);
should we dispose `Graphics2D` object?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1449902105
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1449901861
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1449902602
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1449903249
PR Review Comment: https://git.openjdk.org/jdk/pull/17081#discussion_r1449904073
More information about the client-libs-dev
mailing list