My goal is to prevent setEnabled in Swing from graying out my JLabels and other JComponents into unreadability. (The reason for this is that I have another solution to indicate enabled status - icons.)
Based on SO answers to one of my previous questions, I decided to override setEnabled. Yet as you will find below, my overriding of setEnabled still results in components becoming grayed out, despite the lack of any call to super(toggle). Can someone explain why it appears impossible effectively to override setEnabled's behaviour?
public class ToggleLabel extends JLabel {
private boolean toggle;
public ToggleLabel(String text, boolean toggle) {
super(text);
setEnabled(toggle);
}
public ToggleLabel(Icon image, boolean toggle) {
super(image);
setEnabled(toggle);
}
@Override
public void setEnabled(boolean toggle) {
this.toggle = toggle;
System.out.println("I am used");
}
@Override
public boolean isEnabled() {
return toggle;
}
}