Evenement de click sur une cellule de JTable
salut tous
je veux appliquer un evenement de click sur une cellule de jtable pour la modifier.
j ai appliqué une fonction qui fais l édition automatique de la base dans une classe qui hérite de TableCellRenderer.
et ca marche mais le compilateur me donne beaucoup de warnings qui interrompent le programme par la suite voici le code
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
class DemoCellRenderer extends JLabel implements TableCellRenderer {
boolean isBordered = true;
Color selectedForeground = null;
Color selectedBackground = null;
Color unselectedForegroundAlt = null;
Color unselectedBackgroundAlt = new Color( 255, 255, 255 );
Color unselectedForeground = null;
Color unselectedBackground = null;
public DemoCellRenderer() {
super();
setOpaque(true);
}
//pour remplir le tableau
public Component getTableCellRendererComponent(
JTable table, Object val,
boolean isSelected, boolean hasFocus,
int row, int column) {
setAlignmentX( CENTER_ALIGNMENT );
Font f = getFont();
if ( isSelected ) {
setFont( new Font( f.getName(), Font.PLAIN|Font.ITALIC, f.getSize() ) );
super.setForeground( ( selectedForeground != null) ? selectedForeground : table.getSelectionForeground() );
super.setBackground( ( selectedBackground != null) ? selectedBackground : table.getSelectionBackground() );
}
else {
setFont( new Font( f.getName(), Font.PLAIN, f.getSize() ) );
if ( ((column)>>1)<<1 == column - (row-((row>>1)<<1)) ) {
super.setForeground( ( unselectedForegroundAlt != null) ? unselectedForegroundAlt : table.getForeground() );
super.setBackground( ( unselectedBackgroundAlt != null) ? unselectedBackgroundAlt : table.getBackground() );
}
else {
super.setForeground( ( unselectedForeground != null) ? unselectedForeground : table.getForeground() );
super.setBackground( ( unselectedBackground != null) ? unselectedBackground : table.getBackground() );
}
}
setText( (String)val );
//mise a jour de la base de données automatiquement.
update_Row(column);
return this;
}
} |
et merci en avance :lol: