I am trying to clear data from a JTable but without any success. I know that there are several questions about this but nothing seems to work for me.
When the apply button is clicked data, given by segrAcc.getNewRec() that returns an arrayList, should be updated by removing existing rows and add new ones, but rows are not removed.
static ArrayList<String[]> patRep = new ArrayList<>();
private void applyActionPerformed(java.awt.event.ActionEvent evt) {
model=(DefaultTableModel) tabDaAcc.getModel();
model.setRowCount(0);
for(int i=0;i<segrAcc.getNewRec().size(); i++) {
if (chosenRep.getSelectedItem().equals(segrAcc.getNewRec().get(i)[2])) {
pazDiRep.add(segAcc.getNewRec().get(i));
}
}
for(int i=0;i<patRep.size(); i++) {
String codiceRicovero = patRep.get(i)[0];
String codiceFiscale = patRep.get(i)[1];
String dInizio = patRep.get(i)[3];
String dFine = patRep.get(i)[4];
Object[] data = {codiceRicovero,codiceFiscale,dInizio,dFine};
model.addRow(data);
}
}
What's wrong with this code? thank you
Aucun commentaire:
Enregistrer un commentaire