Salut,
Je veux avoir ma liste en ligne altérnée (une ligne avec une couleur et l'autre non)
j'ai umplémenter la classe
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public class Rendu extends JLabel 
     implements ListCellRenderer { public Component getListCellRendererComponent(
       JList list,                  // Reference à ta liste
       Object value,            // valeur à afficher
       int index,                 // index de la ligne à afficher
       boolean isSelected,      // indique si ta ligne est sélectionnée
       boolean cellHasFocus)    
     {
         String s = value.toString();
         setText(s); // affiche la ligne
         if (isSelected) 
         {
        setBackground(Color.green);
	setForeground(list.getSelectionForeground());
         }
         else 
         {
	list.setBackground(Color.red);
	setForeground(list.getForeground());
         }
        setEnabled(list.isEnabled());
         setFont(list.getFont());
         setOpaque(true);
         return this;}}
Mais le probléme comment je fais l'appel dans ma propore List pour qu'elle soit altérnée ?