import javax.swing.table.TableCellRenderer;
import javax.swing.JTable;
import javax.swing.JLabel;
import java.awt.Component;
import java.awt.Color;

/**
 * This class allows the changing of colors in a specific cell in a JTable
 * @author  Michael Pell, Solutions Plus, Inc.
 */

public class ColorTableCellRenderer extends JLabel implements TableCellRenderer 
{ 
	
	public ColorTableCellRenderer() 
	{ 
		super(); 
		setOpaque(true); /* itīs essential */  
	}
	public Component getTableCellRendererComponent( JTable table, Object value, 
		boolean isSelected, boolean hasFocus, int row, int column) 
	{ 
			String text = (String)value; 
			if(text.equals(dataccesstool.application.TransferPackage.WAITING)) 
				setBackground(Color.yellow); // Decides the color 
			else 
			if( text.equals(dataccesstool.application.TransferPackage.CANCELLED) ) 
				setBackground(Color.red);  
			else 
			if( text.equals(dataccesstool.application.TransferPackage.FAILED)  ) 
				setBackground(Color.red);  
			else 
			if(text.equals(dataccesstool.application.TransferPackage.COMPLETE)) 
				setBackground(Color.green);  
			
			setText(text); /* Put the current text in the JLabel */ 

			return this;
	}
}
