Hi;
I set disabled text color of JCheckBox but I have a problem if I have more than one. I did following;
JCheckBox check1 = new JCheckBox("test");
JCheckBox check2 = new JCheckBox("test1");
UIManager.put("CheckBox.disabledText", Color.Red);
SwingUtilities.updateComponentTreeUI(check1);
When I do this its sets look and feel of other checkboxes too. Please help ?
Regards
Here is the full sample code:
import java.awt.Color;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class Sample extends JFrame {
public Sample () {
this.setSize(400, 400);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel myFrame = new JPanel();
myFrame.setSize(200,200);
JCheckBox check1 = new JCheckBox("check1");
JCheckBox check2 = new JCheckBox("check2");
check1.setSize(50,50);
check2.setSize(50, 50);
check1.setEnabled(false);
check2.setEnabled(false);
UIManager.put("CheckBox.disabledText", Color.BLUE);
SwingUtilities.updateComponentTreeUI(check1);
//or
//check1.updateUI();
myFrame.add(check1);
myFrame.add(check2);
this.add(myFrame);
}
public static void main(String []args) {
new Sample().setVisible(true);
}
}