How can I make some of my JComboBox Items not Selectable? I tried this:
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (not selectable conditions){
comp.setEnabled(false);
comp.setFocusable(false);
} else {
comp.setEnabled(true);
comp.setFocusable(true);
}
return comp;
}
The items become gray, but are still selectable by the user.