diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index f645add8f45..9f1b468007f 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2022, 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 @@ -286,18 +286,6 @@ class GTKStyle extends SynthStyle implements GTKConstants { } } } - - if ((c instanceof JCheckBox) && (state & SynthConstants.DISABLED) != 0) { - if (UIManager.getColor("CheckBox.disabledText") != null) { - return UIManager.getColor("CheckBox.disabledText"); - } - } else if ((c instanceof JRadioButton) && - (state & SynthConstants.DISABLED) != 0) { - if (UIManager.getColor("RadioButton.disabledText") != null) { - return UIManager.getColor("RadioButton.disabledText"); - } - } - return getColorForState(context, type); } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java index e648fbf108e..f25b25166bc 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2022, 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 @@ -779,14 +779,6 @@ public abstract class SynthStyle { (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND)) { return getColorForState(context, type); - } else if (c instanceof JCheckBox) { - if (UIManager.getColor("CheckBox.disabledText") != null) { - return UIManager.getColor("CheckBox.disabledText"); - } - } else if (c instanceof JRadioButton) { - if (UIManager.getColor("RadioButton.disabledText") != null) { - return UIManager.getColor("RadioButton.disabledText"); - } } } diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index 4e00b2c1482..17bad35da71 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -662,6 +662,7 @@ javax/swing/JFileChooser/6798062/bug6798062.java 8146446 windows-all javax/swing/JPopupMenu/4870644/bug4870644.java 8194130 macosx-all,linux-all javax/swing/dnd/8139050/NativeErrorsInTableDnD.java 8202765 macosx-all,linux-all javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all +javax/swing/JRadioButton/4314194/bug4314194.java 8298153 linux-all # Several tests which fail on some hidpi systems/macosx12-aarch64 system java/awt/Window/8159168/SetShapeTest.java 8274106 macosx-aarch64 diff --git a/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java b/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java index e783b147ca6..57ee1a2bb3f 100644 --- a/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java +++ b/test/jdk/javax/swing/JRadioButton/4314194/bug4314194.java @@ -23,7 +23,7 @@ /* * @test * @key headful - * @bug 4314194 8075916 + * @bug 4314194 8075916 8298083 * @summary Verifies disabled color for JCheckbox and JRadiobutton is honored in all L&F * @run main bug4314194 */ @@ -40,13 +40,14 @@ import javax.swing.JRadioButton; import javax.swing.SwingUtilities; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.synth.SynthLookAndFeel; public class bug4314194 { - private static JFrame frame; - private static JRadioButton radioButton; - private static JCheckBox checkBox; - private static Point point; - private static Rectangle rect; + private static volatile JFrame frame; + private static volatile JRadioButton radioButton; + private static volatile JCheckBox checkBox; + private static volatile Point point; + private static volatile Rectangle rect; private static Robot robot; private static final Color radioButtonColor = Color.RED; private static final Color checkboxColor = Color.GREEN; @@ -87,9 +88,25 @@ public class bug4314194 { } } - private static void createUI() { - UIManager.getDefaults().put("CheckBox.disabledText", checkboxColor); - UIManager.getDefaults().put("RadioButton.disabledText", radioButtonColor); + private static void createUI(String laf) { + if (UIManager.getLookAndFeel() instanceof SynthLookAndFeel) { + // reset "basic" properties + UIManager.getDefaults().put("CheckBox.disabledText", null); + UIManager.getDefaults().put("RadioButton.disabledText", null); + // set "synth" properties + UIManager.getDefaults().put("CheckBox[Disabled].textForeground", checkboxColor); + // for some reason the RadioButton[Disabled] does not work + // see https://bugs.openjdk.org/browse/JDK-8298149 + //UIManager.getDefaults().put("RadioButton[Disabled].textForeground", radioButtonColor); + UIManager.getDefaults().put("RadioButton[Enabled].textForeground", radioButtonColor); + } else { + // reset "synth" properties + UIManager.getDefaults().put("CheckBox[Disabled].textForeground", null); + UIManager.getDefaults().put("RadioButton[Enabled].textForeground", null); + // set "basic" properties + UIManager.getDefaults().put("CheckBox.disabledText", checkboxColor); + UIManager.getDefaults().put("RadioButton.disabledText", radioButtonColor); + } checkBox = new JCheckBox("\u2588".repeat(5)); radioButton = new JRadioButton("\u2588".repeat(5)); @@ -98,7 +115,7 @@ public class bug4314194 { checkBox.setEnabled(false); radioButton.setEnabled(false); - frame = new JFrame("bug4314194"); + frame = new JFrame(laf); frame.getContentPane().add(radioButton, BorderLayout.SOUTH); frame.getContentPane().add(checkBox, BorderLayout.NORTH); frame.pack(); @@ -122,7 +139,7 @@ public class bug4314194 { System.out.println("Testing L&F: " + laf.getClassName()); SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); try { - SwingUtilities.invokeAndWait(() -> createUI()); + SwingUtilities.invokeAndWait(() -> createUI(laf.getName())); robot.waitForIdle(); robot.delay(1000); @@ -141,4 +158,3 @@ public class bug4314194 { } } } -