001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.conflict.pair;
003
004import java.awt.Component;
005
006import javax.swing.JLabel;
007import javax.swing.JList;
008import javax.swing.ListCellRenderer;
009
010import org.openstreetmap.josm.gui.conflict.ConflictColors;
011
012public class ComparePairListCellRenderer extends JLabel implements ListCellRenderer<ComparePairType> {
013
014    /**
015     * Constructs a new {@code ComparePairListCellRenderer}.
016     */
017    public ComparePairListCellRenderer() {
018        setOpaque(true);
019    }
020
021    @Override
022    public Component getListCellRendererComponent(
023            JList<? extends ComparePairType> list,
024            ComparePairType value,
025            int index,
026            boolean isSelected,
027            boolean cellHasFocus) {
028        setText(value.getDisplayName());
029        setBackground(isSelected ? ConflictColors.BGCOLOR_SELECTED.get() : ConflictColors.BGCOLOR.get());
030        setForeground(ConflictColors.FGCOLOR.get());
031        return this;
032    }
033}