How to change one object's color while useing Flatlaf

426 Views Asked by At
  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

1

There are 1 best solutions below

0
Alpha On

Use "style" can do this.

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

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