/*
 * ColorsListCellRenderer.java
 *
 * Created on September 27, 2006, 9:13 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package it.businesslogic.ireport.gui.sheet;

import java.awt.Color;
import java.awt.Component;
import java.awt.image.BufferedImage;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

/**
 *
 * @author gtoffoli
 */

import java.awt.Color;
import java.awt.Component;
import java.awt.image.BufferedImage;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;

/**
 *
 * @author gtoffoli
 */
public class ColorsListCellRenderer extends DefaultListCellRenderer  {
           
    /** Creates a new instance of ColorsListCellRenderer */
    public ColorsListCellRenderer() {
        super();
    }
    
    
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        
        if (value instanceof java.awt.Color)
        {
            java.awt.Color color = (java.awt.Color)value;
            
            label.setText("[" + color.getRed() + "," + color.getGreen() + "," +  color.getBlue()+ "]"  );
            label.setIcon(new ColorIcon(color));
        }
        else
        {
            label.setIcon(new ColorIcon(java.awt.Color.WHITE));
        }
        
        //setBackground(isSelected ? selectionBackground : background);
        return label;
    }
   
}

