I have a JComboBox contains following iems
{ "select" , "one" , "two" }
i need a separate background for first item so , i have made a condition in it's renderer like
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null){
Item item = (Item)value;
setText(item.getDescription());
}
if(index==-1){
setBackground(new Color(199,209,210));
setForeground(Color.BLACK);
}
return this;
}
}
so my question is if we disable a JComboBox, i have to made -1th index of component background color to someother color
like
if(index==-1){
setBackground(Color.RED);
}
please advice