Skip to content

Commit c51bed7

Browse files
committed
8335986: Test javax/swing/JCheckBox/4449413/bug4449413.java fails on Windows 11 x64 because RBMenuItem's and CBMenuItem's checkmark on the left side are not visible
Reviewed-by: tr
1 parent a6464b7 commit c51bed7

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 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
@@ -24,7 +24,6 @@
2424
/* @test
2525
* @bug 4449413
2626
* @summary Tests that checkbox and radiobuttons' check marks are visible when background is black
27-
* @author Ilya Boyandin
2827
* @run main/manual bug4449413
2928
*/
3029

@@ -56,8 +55,16 @@
5655

5756
public class bug4449413 extends JFrame {
5857

58+
private static boolean isWindowsLF;
59+
60+
private static String INSTRUCTIONS_WINDOWSLF =
61+
"There are eight controls, JCheckBox/JRadioButton with black background\n" +
62+
"and JRadioButtonMenuItem/JCheckboxMenuItem with gray background\n";
63+
5964
private static final String INSTRUCTIONS =
60-
"There are eight controls with black backgrounds.\n" +
65+
"There are eight controls with black backgrounds.\n";
66+
67+
private static final String INSTRUCTIONS_COMMON =
6168
"Four enabled (on the left side) and four disabled (on the right side)\n" +
6269
"checkboxes and radiobuttons.\n\n" +
6370
"1. If at least one of the controls' check marks is not visible:\n" +
@@ -82,6 +89,8 @@ boolean isMetalLookAndFeel() {
8289
}
8390

8491
public static void main(String[] args) throws Exception {
92+
isWindowsLF = "Windows".equals(UIManager.getLookAndFeel().getID());
93+
8594
SwingUtilities.invokeLater(() -> {
8695
instance = new bug4449413();
8796
instance.createAndShowGUI();
@@ -150,8 +159,10 @@ public void addComponentsToPane() {
150159

151160
JTextArea instructionArea = new JTextArea(
152161
isMetalLookAndFeel()
153-
? INSTRUCTIONS + INSTRUCTIONS_ADDITIONS_METAL
154-
: INSTRUCTIONS
162+
? INSTRUCTIONS + INSTRUCTIONS_COMMON + INSTRUCTIONS_ADDITIONS_METAL
163+
: isWindowsLF
164+
? (INSTRUCTIONS_WINDOWSLF + INSTRUCTIONS_COMMON)
165+
: (INSTRUCTIONS + INSTRUCTIONS_COMMON)
155166
);
156167

157168
instructionArea.setEditable(false);
@@ -189,7 +200,13 @@ static AbstractButton createButton(int enabled, int type) {
189200
};
190201

191202
b.setOpaque(true);
192-
b.setBackground(Color.black);
203+
if (isWindowsLF
204+
&& ((b instanceof JRadioButtonMenuItem)
205+
|| (b instanceof JCheckBoxMenuItem))) {
206+
b.setBackground(Color.lightGray);
207+
} else {
208+
b.setBackground(Color.black);
209+
}
193210
b.setForeground(Color.white);
194211
b.setEnabled(enabled == 1);
195212
b.setSelected(true);

0 commit comments

Comments
 (0)