i have a ComboBox named 'ComboBox_status' which have default values 'In Operation' and 'Disposed'
i want the background color to change to red when 'Disposed' is selected and green when 'In Operation' is selected.

this is the code i tried but it changes the background to red for both of them when they are selected

String age="Disposed";

        if("Disposed".equals(age)){
                  ComboBox_status.setBackground(Color.red); 
                  ComboBox_status.setForeground(Color.BLACK);
                }
                else{
                    ComboBox_status.setBackground(Color.GREEN);
                    ComboBox_status.setForeground(Color.darkGray);

                }  

i will appreciate it if anyone could help me resolve this THANK YOU.

how do you expect this to return false:

String age="Disposed";
if("Disposed".equals(age)){

basically: what you are doing is:

if ( true ) 
  setColor(RED);
else
  setColor(BLACK);

and for some reason, you expect the else block to be executed. don't hardcode the value of age, get the value selected in your JComboBox

btw job for Renderer