posted 21 years ago
Dear Friends
I have a combobox say it contains the following elements
Arial
Courier
Arjun
windings
verdana
default
dialog
*************
Now i have a list which contains
Arial
Courier
Arjun
******
My problem is that in the combobox those elements which are not there in the list must be displayed in RED Color.
Please help me its urgent.
I tried to use ListCellRenderer, but it makes all the elements as RED
Here i just tried to diplay arial and arjun fonts in RED. its not working
class MyCellRenderer extends JLabel implements ListCellRenderer{
public MyCellRenderer(){
setOpaque(true);
}
public Component getListCellRendererComponent(JList list,
Object value,int index, boolean isSelected,boolean cellHasFocus)
{
setText(value.toString());
if(value.toString().equals("Arial"))
{
setBackground(getBackground());
setForeground(Color.red);
System.out.println("In if ......");
}
if(value.toString().equals("Arjun")) {
setBackground(getBackground());
setForeground(Color.red);
System.out.println("In if ......");
}else {
setBackground(getBackground());
setForeground(Color.black);
System.out.println("In else ......");
}
return this;
}
}