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
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
5655
5756public 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