package com.androhi.androiddrawableviewer.form;

import com.intellij.ui.JBColor;

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

public class ImageListCellRenderer implements ListCellRenderer {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        if (value instanceof JPanel) {
            Component component = (Component) value;
            component.setForeground(JBColor.white);
            Color normalBackground = index % 2 == 0 ? JBColor.border() : JBColor.background();
            component.setBackground(isSelected ? UIManager.getColor("List.selectionBackground") : normalBackground);
            return component;
        } else {
            return new JLabel("");
        }
    }
}

@@ -182,16 +182,17 @@
 derer %7B%0A
+%0A
     @Ove
@@ -363,24 +363,81 @@
 f JPanel) %7B%0A
+            setLabelColor(((JPanel) value), isSelected);%0A
             
@@ -481,60 +481,8 @@
 ue;%0A
-            component.setForeground(JBColor.white);%0A
     
@@ -736,16 +736,16 @@
  else %7B%0A
-
         
@@ -786,11 +786,309 @@
  %7D%0A    %7D
+%0A%0A    private void setLabelColor(JPanel panel, boolean isSelected) %7B%0A        Component%5B%5D components = panel.getComponents();%0A        for (Component cmp : components) %7B%0A            cmp.setForeground(isSelected ? UIManager.getColor(%22List.selectionForeground%22) : JBColor.foreground());%0A        %7D%0A    %7D
 %0A%7D%0A

Modify list foreground color