Skip to content

Commit c2e14b1

Browse files
author
Abhishek Kumar
committed
8343891: Test javax/swing/JTabbedPane/TestJTabbedPaneBackgroundColor.java failed
Reviewed-by: aivanov, psadhukhan
1 parent 52c6ce6 commit c2e14b1

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

test/jdk/javax/swing/JTabbedPane/TestJTabbedPaneBackgroundColor.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
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
@@ -48,17 +48,22 @@ public class TestJTabbedPaneBackgroundColor {
4848
private static Robot robot;
4949
private static volatile Dimension dim;
5050
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;
5154

5255
public static void main(String[] args) throws Exception {
5356
robot = new Robot();
5457

5558
for (UIManager.LookAndFeelInfo laf :
5659
UIManager.getInstalledLookAndFeels()) {
5760
System.out.println("Testing: " + laf.getName());
58-
setLookAndFeel(laf);
5961

6062
try {
61-
SwingUtilities.invokeAndWait(TestJTabbedPaneBackgroundColor::createAndShowUI);
63+
SwingUtilities.invokeAndWait(() -> {
64+
setLookAndFeel(laf);
65+
createAndShowUI();
66+
});
6267
robot.waitForIdle();
6368
robot.delay(500);
6469

@@ -70,10 +75,12 @@ public static void main(String[] args) throws Exception {
7075
loc = new Point(loc.x + dim.width - 2, loc.y + 2);
7176
doTesting(loc, laf);
7277

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+
});
7784
robot.waitForIdle();
7885
robot.delay(500);
7986

@@ -119,14 +126,18 @@ private static void createAndShowUI() {
119126
frame.setVisible(true);
120127
}
121128

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+
});
124135
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;
128137

129138
if (!expected.equals(actual)) {
139+
System.out.println("Expected Color : " + expected);
140+
System.out.println("Actual Color : " + actual);
130141
addOpaqueError(laf.getName(), isOpaque);
131142
}
132143
}

0 commit comments

Comments
 (0)