JavaTechnical
JavaTechnical

Reputation: 9357

How to set disabled text color for JLabel?

How to set the disabled text color for every JLabel in my program. It is not in the docs . Is there any way to set the disabled foreground color for it?

Upvotes: 3

Views: 3234

Answers (1)

JavaTechnical
JavaTechnical

Reputation: 9357

I got it. Foreground can be set using UI Defaults.

// Use the key, Label.disabledForeground
UIManager.put("Label.disabledForeground",Color.RED);

JLabel l=new JLabel("Label Disabled");
l.setEnabled(false);
// You get a red foreground

For NimbusLookAndFeel

UIManager.put("Label[Disabled].textForeground",Color.RED);

Upvotes: 3

Related Questions