I noticed that when i move the cursor over any cell of the table, the function 'getValueAt' gets called, showing into the Eclipse console its output. Was just wondering why, shouldn't it be called only when i create the tableModel object?
I created a class, ModelloTabella which implements tableModel and this is TableModel getValueAt implementation:
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Studente tmp=arrayStudenti.get(rowIndex);
if(columnIndex==0){
System.out.println("Stampo da getValueAt Matricola");
return tmp.getMatricola();
}else if(columnIndex==1){
System.out.println("Stampo da getValueAt Nome");
return tmp.getNome();
}else{
System.out.println("Stampo da getValueAt Cognome");
return tmp.getCognome();
}
}
This is where the object 'ModelloTabella' is created. I thought the function was called here only:
model = new ModelloTabella(this.controller.caricaStudenti(),controller);
Tabella.setModel(model);