public Component getListCellRendererComponent( final JList list, final Object value, @SuppressWarnings("unused") final int index, final boolean isSelected, @SuppressWarnings("unused") final boolean cellHasFocus) { if (value instanceof ModelItem) { final ModelItem item = (ModelItem) value; setText(item.getDisplayName()); setIcon(item.getIcon()); } else { setText(value.toString()); setIcon(null); } if (isSelected) { setBackground(list.getSelectionBackground()); setForeground(list.getSelectionForeground()); } else { setBackground(list.getBackground()); setForeground(list.getForeground()); } return this; }