Results 1 to 2 of 2
  1. #1
    dinu is offline Member
    Join Date
    Jan 2013
    Posts
    31
    Rep Power
    0

    Default how do i implement rendering in different class ?

    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 ?

    Java Code:
                         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;
                               
                             }
    thanks

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: how do i implement rendering in different class ?

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Implement a class Automobile
    By Tiger in forum New To Java
    Replies: 10
    Last Post: 02-01-2013, 03:25 AM
  2. Replies: 15
    Last Post: 02-04-2012, 11:15 PM
  3. Replies: 0
    Last Post: 01-24-2011, 04:10 PM
  4. Replies: 1
    Last Post: 10-02-2009, 01:35 AM
  5. Implement a class Employee-Help due tmrw!
    By Britt7 in forum New To Java
    Replies: 3
    Last Post: 10-27-2008, 01:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •