ciao andbin
potresti farmi un esempio ?mantenere sempre lo stesso oggetto model e aggiornare solo la sua struttura dati interna e poi notificare le modifiche.
comunque questo e il mio model :
codice:public class ModelloTabella extends AbstractTableModel { public ModelloTabella(ResultSet aResultset){ rs = aResultset; try{ rsmd = rs.getMetaData(); }catch (SQLException e){e.printStackTrace();} } public String getColumnName(int c){ try{ //metodo che setta i nomi delle colonne String str=rsmd.getColumnName(c+1); if (str.equals("id_macchina"))str ="N° Macchina"; if (str.equals("nome"))str ="Macchina"; if (str.equals("descrizione"))str ="Descrizione"; if (str.equals("Fascia_max"))str ="Fascia Max"; return str; }catch(SQLException e){e.printStackTrace(); return "";} } public int getColumnCount() { // metodo che conta le colonne try{ return rsmd.getColumnCount(); }catch(SQLException e){e.printStackTrace(); return 0;} } public int getRowCount() { //metodo che conta le righe try{ rs.last(); return rs.getRow(); }catch(SQLException e){e.printStackTrace();return 0;} } public Object getValueAt(int r, int c) { // metodo che aggiunge l'oggetto alla tabella try{ rs.absolute(r+1); return rs.getObject(c+1); }catch(SQLException e){e.printStackTrace();return null;} } private ResultSet rs; private ResultSetMetaData rsmd; }

Rispondi quotando