'How to change one object's color while useing Flatlaf

  1. This will change all the JRadioButton's checkmark color.

    UIManager.put( "CheckBox.icon.checkmarkColor", Color.red );
    LookAndFeel lookAndFeel = UIManager.getLookAndFeel();
    try {
        UIManager.setLookAndFeel( lookAndFeel );
    } catch (UnsupportedLookAndFeelException ex) {
        ex.printStackTrace();
    }
    updateUI();
    
  2. And then I want to only change radiobutton1's color while I click another button. But it does not work.

    radiobutton1.putClientProperty( "CheckBox.icon.checkmarkColor",Color.yellow);
    

enter image description here



Solution 1:[1]

Use "style" can do this.

radiobutton1.putClientProperty( FlatClientProperties.STYLE,"icon.checkmarkColor:#ffff66");

This can change only radiobutton1's "icon.checkmarkColor".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alpha