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