This discussion is archived
2 Replies Latest reply: Apr 26, 2013 5:54 AM by thomas.behr RSS

how do i implement rendering in different class ?

1003640 Newbie
Currently Being Moderated
This is a snippet in main program which colors the rows. I want to implement this in different class and call that class.
How do i do that ?
    table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer()    
                      {
                         @Override
                       public Component getTableCellRendererComponent(JTable table,
                               Object value, boolean isSelected, boolean hasFocus, int row,int column) 
                         {
                            Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus,row, column);
                                Boolean last=(Boolean)table.getValueAt(row, 4);       
                                String status=(String)table.getValueAt(row, 3);  
                                if(Boolean.TRUE.equals(last) && status.equals("ACK"))
                                     {
                                     c.setBackground(Color.green);
                                    }
                                else if(Boolean.TRUE.equals(last) && status.equals("nil"))
                                  {
                                  c.setBackground(Color.yellow);
                                 }
                                else
                                   {
                               c.setBackground(Color.red);
                                   }
                                table.repaint();
                            return c;
                           
                         }
Edited by: 1000637 on Apr 23, 2013 9:46 PM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points