package com.connor.ml.tcm.outfile.ML_01;

import java.awt.Component;
import java.util.List;

import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.EventListenerList;
import javax.swing.table.TableCellRenderer;


public class TableCellCheckboxRenderer extends JCheckBox implements
		TableCellRenderer {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<Integer> processRows;
	protected EventListenerList listenerList = new EventListenerList();
	protected ChangeEvent changeEvent = new ChangeEvent(this);
	//private TestTreeTableModel tableModel;

	public List<Integer> getProcessRows() {
		return processRows;
	}

	public void setProcessRows(List<Integer> processRows) {
		this.processRows = processRows;
		
	}
	
	public TableCellCheckboxRenderer(final JTreeTable table) {
		
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		// TODO Auto-generated method stub
        this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中
        this.setBorderPainted(true);

        if(value != null)
        {
//        	if(value.toString().equals("1"))
//        	{
//        		if(table.getColumnName(column).equals("改制") && hasFocus)
//            	{
//        			if(table.getValueAt(row, column + 1).toString().equals("1"))
//	        		{
//	        			table.setValueAt(0, row, column + 1);
//	        		}
//            	}
//        		else if(table.getColumnName(column).equals("删除") && hasFocus)
//            	{
//        			if(table.getValueAt(row, column - 1).toString().equals("1"))
//	        		{
//	        			table.setValueAt(0, row, column - 1);
//	        		}
//            	}
//        	}
//        	if(value.toString().equals("1"))
//        	{
//        		System.out.println(value.toString().equals("1") + "====");
//        	}
    		this.setSelected(value.toString().equals("1"));
        }
        else
        {
        	this.setSelected(false);
        }
		return this;
	}
}