Skip to content

Commit

Permalink
8343902: javax/swing/plaf/nimbus/8041642/bug8041642.java fails in ubu…
Browse files Browse the repository at this point in the history
…ntu22.04

Reviewed-by: azvegint
  • Loading branch information
prsadhuk committed Nov 19, 2024
1 parent b12c5b4 commit 499186b
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions test/jdk/javax/swing/plaf/nimbus/8041642/bug8041642.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -26,11 +26,21 @@
* @key headful
* @bug 8041642 8079450 8140237
* @summary Incorrect paint of JProgressBar in Nimbus LF
* @author Semyon Sadetsky
*/

import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class bug8041642 {

Expand All @@ -50,17 +60,24 @@ public void run() {
}
});
final Robot robot = new Robot();
robot.delay(300);
robot.waitForIdle();
robot.delay(1000);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
point = bar.getLocationOnScreen();
}
});
Color color = robot.getPixelColor(point.x + 1, point.y + 7);
System.out.println(color);
System.out.println("point " + point + " color " + color);
if (color.getGreen() < 150 || color.getBlue() > 30 ||
color.getRed() > 200) {
Rectangle bounds = frame.getBounds();
BufferedImage img = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);
Graphics g = img.getGraphics();
frame.paint(g);
g.dispose();
ImageIO.write(img, "png", new File("bug8041642.png"));
throw new RuntimeException("Bar padding color should be green");
}

Expand Down

0 comments on commit 499186b

Please sign in to comment.