Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how do i implement rendering in different class ?

1003640Apr 24 2013 — edited Apr 26 2013
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2013
Added on Apr 24 2013
2 comments
119 views