1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
24
24
/* @test
25
25
* @bug 4449413
26
26
* @summary Tests that checkbox and radiobuttons' check marks are visible when background is black
27
- * @author Ilya Boyandin
28
27
* @run main/manual bug4449413
29
28
*/
30
29
56
55
57
56
public class bug4449413 extends JFrame {
58
57
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
+
59
64
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 =
61
68
"Four enabled (on the left side) and four disabled (on the right side)\n " +
62
69
"checkboxes and radiobuttons.\n \n " +
63
70
"1. If at least one of the controls' check marks is not visible:\n " +
@@ -82,6 +89,8 @@ boolean isMetalLookAndFeel() {
82
89
}
83
90
84
91
public static void main (String [] args ) throws Exception {
92
+ isWindowsLF = "Windows" .equals (UIManager .getLookAndFeel ().getID ());
93
+
85
94
SwingUtilities .invokeLater (() -> {
86
95
instance = new bug4449413 ();
87
96
instance .createAndShowGUI ();
@@ -150,8 +159,10 @@ public void addComponentsToPane() {
150
159
151
160
JTextArea instructionArea = new JTextArea (
152
161
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 )
155
166
);
156
167
157
168
instructionArea .setEditable (false );
@@ -189,7 +200,13 @@ static AbstractButton createButton(int enabled, int type) {
189
200
};
190
201
191
202
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
+ }
193
210
b .setForeground (Color .white );
194
211
b .setEnabled (enabled == 1 );
195
212
b .setSelected (true );
0 commit comments