Skip to content

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 #25864

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions test/jdk/javax/swing/JCheckBox/4449413/bug4449413.java
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
*/

Expand Down Expand Up @@ -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" +
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down