How can I make some of my JComboBox items inaccessible? 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; }
Elements turn gray, but are still available to the user.
source share