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
| public class MatriceTableModel extends AbstractTableModel {
public int[][] matrice;
public MatriceTable(int[][] matrice) {
this.matrice = matrice;
}
public int[][] getMatrice() {
return this.matrice;
}
public void setMatrice(int[][] matrice) {
this.matrice = matrice;
this.fireTableStructureChanged();
}
@Override
public int getRowCount() {
return matrice.length;
}
@Override
public int getColumnCount() {
return matrice[0].length;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return Integer.class;
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return this.matrice[rowIndex][columnIndex];
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
this.matrice[rowIndex][columnIndex] = (Integer)aValue;
}
} |
Partager