I can not view each value on the same line. It is displayed per column. Every dealer in the total column line should display the sum of all values.
I do not know how to display line by line.
String[]entete= {"Revendeur/Montant","5000","3000","1500","800","600","500","400","REMISE","TOTAL","CREANCE"};
Object [][]donnees= {{"Patrick",0,0,0,0,0,0,0,0,0,""},
{"Marie",0,0,0,0,0,0,0,0,0,""},
{"Christian",0,0,0,0,0,0,0,0,0,""},
{"Fabian",0,0,0,0,0,0,0,0,0,""},
{"TOTAL",0,0,0,0,0,0,0,0,0,""}};
private void setTableModelListener() {
tableModelListener = new TableModelListener() {
public void tableChanged(TableModelEvent e) {
int lastRow = model.getRowCount()-1 ;
int lastColumn = model.getColumnCount()-2 ; //Colonne total
int rowCount = model.getRowCount();
if (e.getType() == TableModelEvent.UPDATE && e.getColumn() < lastColumn && e.getFirstRow() < lastRow && e.getLastRow() < lastRow ) {
int row = rowCount;
int value = 0;// on initialise le résultat
int value1 = 0;
int value2 = 0;
int value3 = 0;
int value4 = 0;
int value5 = 0;
int value6 = 0;
for (int i = 0; i < row; i++) {
value += 5000*(int) model.getValueAt(i, 1); // cumul montant
value1 += 3000*(int) model.getValueAt(i, 2);
value2 += 1500*(int) model.getValueAt(i, 3);
value3 += 800*(int) model.getValueAt(i, 4);
value4 += 600*(int) model.getValueAt(i, 5);
value5 += 500*(int) model.getValueAt(i, 6);
value6 += 400*(int) model.getValueAt(i, 7);
}
model.setValueAt(value, 0, lastColumn);
model.setValueAt(value1, 1, lastColumn);
}
}
};
}