Jlist devient non sélectionnable aprés l'implémentation d'un ListCellrender
Bonjour ,
j'utilise le listcellrender en bas pour modifier le style de sertaines lignes d'un liste
sa marchait mais le problème c'est que ma liste devient non sélectionnable , j'ai besoin d'aide svp
LISTCELLRENDER
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
class MyCellRenderer extends JLabel implements ListCellRenderer {
// This is the only method defined by ListCellRenderer.
// We just reconfigure the JLabel each time we're called.
public Component getListCellRendererComponent(
JList list,
Object value, // value to display
int index, // cell index
boolean isSelected, // is the cell selected
boolean cellHasFocus) // the list and the cell have the focus
{
String s = value.toString();
setText(value.toString());
if (s.contains("< Lu >")){
setFont(new java.awt.Font("Courier new", 0, 11));
setForeground(new java.awt.Color(102, 102, 102));
}else
{
setFont(new java.awt.Font("Courier new", 1, 12));
setForeground(new java.awt.Color(0, 0, 0));
setBackground(Color.blue);}
return this;
}
} |