1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
26
26
* @key headful
27
27
* @bug 8041642 8079450 8140237
28
28
* @summary Incorrect paint of JProgressBar in Nimbus LF
29
- * @author Semyon Sadetsky
30
29
*/
31
30
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 ;
34
44
35
45
public class bug8041642 {
36
46
@@ -50,17 +60,24 @@ public void run() {
50
60
}
51
61
});
52
62
final Robot robot = new Robot ();
53
- robot .delay (300 );
63
+ robot .waitForIdle ();
64
+ robot .delay (1000 );
54
65
SwingUtilities .invokeAndWait (new Runnable () {
55
66
@ Override
56
67
public void run () {
57
68
point = bar .getLocationOnScreen ();
58
69
}
59
70
});
60
71
Color color = robot .getPixelColor (point .x + 1 , point .y + 7 );
61
- System .out .println (color );
72
+ System .out .println ("point " + point + " color " + color );
62
73
if (color .getGreen () < 150 || color .getBlue () > 30 ||
63
74
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" ));
64
81
throw new RuntimeException ("Bar padding color should be green" );
65
82
}
66
83
0 commit comments