1
1
/*
2
- * Copyright (c) 2015, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2025 , 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
@@ -48,17 +48,22 @@ public class TestJTabbedPaneBackgroundColor {
48
48
private static Robot robot ;
49
49
private static volatile Dimension dim ;
50
50
private static volatile Point loc ;
51
+ private static volatile boolean isOpaque ;
52
+ private static volatile Color c1 = null ;
53
+ private static volatile Color c2 = null ;
51
54
52
55
public static void main (String [] args ) throws Exception {
53
56
robot = new Robot ();
54
57
55
58
for (UIManager .LookAndFeelInfo laf :
56
59
UIManager .getInstalledLookAndFeels ()) {
57
60
System .out .println ("Testing: " + laf .getName ());
58
- setLookAndFeel (laf );
59
61
60
62
try {
61
- SwingUtilities .invokeAndWait (TestJTabbedPaneBackgroundColor ::createAndShowUI );
63
+ SwingUtilities .invokeAndWait (() -> {
64
+ setLookAndFeel (laf );
65
+ createAndShowUI ();
66
+ });
62
67
robot .waitForIdle ();
63
68
robot .delay (500 );
64
69
@@ -70,10 +75,12 @@ public static void main(String[] args) throws Exception {
70
75
loc = new Point (loc .x + dim .width - 2 , loc .y + 2 );
71
76
doTesting (loc , laf );
72
77
73
- if (!pane .isOpaque ()) {
74
- pane .setOpaque (true );
75
- pane .repaint ();
76
- }
78
+ SwingUtilities .invokeAndWait (() -> {
79
+ if (!pane .isOpaque ()) {
80
+ pane .setOpaque (true );
81
+ pane .repaint ();
82
+ }
83
+ });
77
84
robot .waitForIdle ();
78
85
robot .delay (500 );
79
86
@@ -119,14 +126,18 @@ private static void createAndShowUI() {
119
126
frame .setVisible (true );
120
127
}
121
128
122
- private static void doTesting (Point p , UIManager .LookAndFeelInfo laf ) {
123
- boolean isOpaque = pane .isOpaque ();
129
+ private static void doTesting (Point p , UIManager .LookAndFeelInfo laf ) throws Exception {
130
+ SwingUtilities .invokeAndWait (() -> {
131
+ isOpaque = pane .isOpaque ();
132
+ c1 = pane .getBackground ();
133
+ c2 = frame .getContentPane ().getBackground ();
134
+ });
124
135
Color actual = robot .getPixelColor (p .x , p .y );
125
- Color expected = isOpaque
126
- ? pane .getBackground ()
127
- : frame .getContentPane ().getBackground ();
136
+ Color expected = isOpaque ? c1 : c2 ;
128
137
129
138
if (!expected .equals (actual )) {
139
+ System .out .println ("Expected Color : " + expected );
140
+ System .out .println ("Actual Color : " + actual );
130
141
addOpaqueError (laf .getName (), isOpaque );
131
142
}
132
143
}
0 commit comments