hey all
i have a table in my project which called tasktable it retrives data from database (oracle) how can i change the color of the row that has the color in the cell ex. (i,8) Automatically when i click in refresh butomn

i have tried so many times to put that source code on specifec row but it ended up coloring all the table

`

                     int count;      
                     count = tasktable.getRowCount();
             for (int i=0;i<count;i++)
                { 
                      rr = new Object ();
                       rr = tasktable.getModel().getValueAt(i,8);




                       if(rr.equals("GREEN"))
                       {
                     setBackground(Color.GREEN);
                       }

                        if(rr.equals("red"))
                       {

                           setBackground(Color.red);

                       }
                         if(rr.equals("BLUE"))
                       {

                          setBackground(Color.BLUE);

                       }
                          if(rr.equals("yellow"))
                       {

                         setBackground(Color.yellow);

                       }
                           if(rr.equals("pink"))
                       {

                         setBackground(Color.pink);

                       }
                           if(rr.equals(null))
                       {
                         setBackground(null);


                       }

how can help me out upon this problem ?
`

Recommended Answers

You need a custom cell renderer if you want complete control over the appearance of individual rows/cols/cells in your table. Start learning here:
http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender

Jump to Post

All 2 Replies

test1 this is my user interface

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.