Bonjour,
J'aimerais savoir pourquoi quand j'utilise renderer je peu plus selectionner une case?
Version imprimable
Bonjour,
J'aimerais savoir pourquoi quand j'utilise renderer je peu plus selectionner une case?
Voici le code de mon renderer
j'aimerais savoir pourquoi je ne peu pa selectionner de case dans le tabloCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 public class AfficheFauxJour extends JLabel implements TableCellRenderer { public java.awt.Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { JLabel p=new JLabel(); if (value != null){ p.setForeground(Color.pink); p.setHorizontalAlignment(p.CENTER); p.setText(String.valueOf(value));} p.setBackground(Color.orange); return p; } }
merci d'avance
en esperant avoiretait clair
Bonjour,
Ta cellulle est toujours sélectionnée. Seulement tu ne le vois pas.
Tu as un argument boolean isSelected. Tu dois donc redéfinir la couleur de la cellulle en fonction de cet argument (c'est ce que fais le DefaultCellRenderer).
Bonne chance.
@+
merci mais
j'ai pas compris dsl :oops:
tu peu etre explicit
ben en gros vedaer te dis de faire un condition dans ton objet:
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 public class AfficheFauxJour extends JLabel implements TableCellRenderer { public java.awt.Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { JLabel p=new JLabel(); if (value != null){ p.setForeground(Color.pink); p.setHorizontalAlignment(p.CENTER); p.setText(String.valueOf(value));} if(!isSelected) p.setBackground(Color.orange); return p; } }
MERCI BEAUCOUP
:merci: