/*
 * ComboBoxRenderer.java
 *
 * Created on 2 ottobre 2004, 16.59
 */

package it.businesslogic.ireport.chart.gui;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;

/**
 *
 * @author  Administrator
 */
public class ComboBoxRenderer extends JComboBox implements TableCellRenderer {
        public ComboBoxRenderer(String[] items) {
            super(items);
            setEditable(true);
        }
        
         public ComboBoxRenderer(java.util.Vector items) {
            super(items);
            setEditable(true);
        }
    
        public Component getTableCellRendererComponent(JTable table, Object value,
                boolean isSelected, boolean hasFocus, int row, int column) {
            if (isSelected) {
                setForeground(table.getSelectionForeground());
                super.setBackground(table.getSelectionBackground());
            } else {
                setForeground(table.getForeground());
                setBackground(table.getBackground());
            }
    
            // Select the current value
            setSelectedItem(value);
            return this;
        }
    }

