Skip to content

Commit 499186b

Browse files
committed
8343902: javax/swing/plaf/nimbus/8041642/bug8041642.java fails in ubuntu22.04
Reviewed-by: azvegint
1 parent b12c5b4 commit 499186b

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

test/jdk/javax/swing/plaf/nimbus/8041642/bug8041642.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,11 +26,21 @@
2626
* @key headful
2727
* @bug 8041642 8079450 8140237
2828
* @summary Incorrect paint of JProgressBar in Nimbus LF
29-
* @author Semyon Sadetsky
3029
*/
3130

32-
import javax.swing.*;
33-
import java.awt.*;
31+
import java.io.File;
32+
import java.awt.BorderLayout;
33+
import java.awt.Color;
34+
import java.awt.Graphics;
35+
import java.awt.Point;
36+
import java.awt.Rectangle;
37+
import java.awt.Robot;
38+
import java.awt.image.BufferedImage;
39+
import javax.imageio.ImageIO;
40+
import javax.swing.JFrame;
41+
import javax.swing.JProgressBar;
42+
import javax.swing.SwingUtilities;
43+
import javax.swing.UIManager;
3444

3545
public class bug8041642 {
3646

@@ -50,17 +60,24 @@ public void run() {
5060
}
5161
});
5262
final Robot robot = new Robot();
53-
robot.delay(300);
63+
robot.waitForIdle();
64+
robot.delay(1000);
5465
SwingUtilities.invokeAndWait(new Runnable() {
5566
@Override
5667
public void run() {
5768
point = bar.getLocationOnScreen();
5869
}
5970
});
6071
Color color = robot.getPixelColor(point.x + 1, point.y + 7);
61-
System.out.println(color);
72+
System.out.println("point " + point + " color " + color);
6273
if (color.getGreen() < 150 || color.getBlue() > 30 ||
6374
color.getRed() > 200) {
75+
Rectangle bounds = frame.getBounds();
76+
BufferedImage img = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
77+
Graphics g = img.getGraphics();
78+
frame.paint(g);
79+
g.dispose();
80+
ImageIO.write(img, "png", new File("bug8041642.png"));
6481
throw new RuntimeException("Bar padding color should be green");
6582
}
6683

0 commit comments

Comments
 (0)