The DefaultListCellRenderer
extends JLabel
. In its getListRendererComponent
method, it sets its enabled state based on that of the JList
that is passed in.
The code for painting disabled JLabel
text in BasicLabelUI
does some work to paint the text with a shadow effect. In many subclasses, you will find code that looks for the "Label.disabledForeground"
UI property. The Nimbus defaults seem to look for "Label.disabledText"
.
You have a couple options:
- You can set the
"Label.disabledText"
property in the UIManager
, which will make all JLabel
instances and subclasses that are disabled to take on this coloring.
- You can create a custom renderer for your
JList
that tests the enabled state of the JList
and then does whatever custom code that you would like - or omit the enabled state test entirely if you want it to look the same regardless of its enabled state.
I would suggest that you take the custom renderer approach, as it is difficult to say where the change of a JLabel
property will show up, as that class is used as a builing block in many different components.