/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package plcalc;

import java.awt.*;
import javax.swing.*;

/**
 *
 * @author lutusp
 */
public class MyListCellRenderer extends DefaultListCellRenderer {

    Color[] colors = {new Color(0xff, 0xff, 0xff), new Color(0xf0, 0xf0, 0xf0)};

    public MyListCellRenderer() {
    }

    public Component getListCellRendererComponent(
            JList list,
            Object value,
            int index,
            boolean isSelected,
            boolean cellHasFocus) {
        super.getListCellRendererComponent(
                list,
                value,
                index,
                isSelected,
                cellHasFocus);
        if (!isSelected) {
            setForeground(Color.black);
            setBackground(colors[index % 2]);
        }
        return this;
    }
}