diff --git a/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java b/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java index 1efcfe58a31..d854961ea06 100644 --- a/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java +++ b/test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,6 @@ /* @test * @bug 4449413 * @summary Tests that checkbox and radiobuttons' check marks are visible when background is black - * @author Ilya Boyandin * @run main/manual bug4449413 */ @@ -56,8 +55,16 @@ public class bug4449413 extends JFrame { + private static boolean isWindowsLF; + + private static String INSTRUCTIONS_WINDOWSLF = + "There are eight controls, JCheckBox/JRadioButton with black background\n" + + "and JRadioButtonMenuItem/JCheckboxMenuItem with gray background\n"; + private static final String INSTRUCTIONS = - "There are eight controls with black backgrounds.\n" + + "There are eight controls with black backgrounds.\n"; + + private static final String INSTRUCTIONS_COMMON = "Four enabled (on the left side) and four disabled (on the right side)\n" + "checkboxes and radiobuttons.\n\n" + "1. If at least one of the controls' check marks is not visible:\n" + @@ -82,6 +89,8 @@ boolean isMetalLookAndFeel() { } public static void main(String[] args) throws Exception { + isWindowsLF = "Windows".equals(UIManager.getLookAndFeel().getID()); + SwingUtilities.invokeLater(() -> { instance = new bug4449413(); instance.createAndShowGUI(); @@ -150,8 +159,10 @@ public void addComponentsToPane() { JTextArea instructionArea = new JTextArea( isMetalLookAndFeel() - ? INSTRUCTIONS + INSTRUCTIONS_ADDITIONS_METAL - : INSTRUCTIONS + ? INSTRUCTIONS + INSTRUCTIONS_COMMON + INSTRUCTIONS_ADDITIONS_METAL + : isWindowsLF + ? (INSTRUCTIONS_WINDOWSLF + INSTRUCTIONS_COMMON) + : (INSTRUCTIONS + INSTRUCTIONS_COMMON) ); instructionArea.setEditable(false); @@ -189,7 +200,13 @@ static AbstractButton createButton(int enabled, int type) { }; b.setOpaque(true); - b.setBackground(Color.black); + if (isWindowsLF + && ((b instanceof JRadioButtonMenuItem) + || (b instanceof JCheckBoxMenuItem))) { + b.setBackground(Color.lightGray); + } else { + b.setBackground(Color.black); + } b.setForeground(Color.white); b.setEnabled(enabled == 1); b.setSelected(true);