سؤال

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?

هل كانت مفيدة؟

المحلول

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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top