senti volevo sapere come si fa ad aggiungere un certo numero di righe usando il TableModel?
questo è il mio codice ma nn capisco dovè l'errore
codice:class MyTableModel extends AbstractTableModel implements TableModelListener { // public Object[][] data =new Object[99][6]; // //public Object[][] data= { { new Boolean(false),"zagarolo", "Campione", "Snowboarding", new Integer(5), "ZAGA", "la mam di nicola"}}; public Record[] r= new Record[99]; public Object[][] data= { { new Boolean(false),"zagarolo", "Campione", "Snowboarding", new Integer(5), "ZAGA", "la mam di nicola"}, { new Boolean(false),"zagarolo", "Campione", "Snowboarding", new Integer(5), "ZAGA", "la mam di nicola"}}; public TableModel tm = new TableModel(); public JTable tt= new JTable(); private boolean DEBUG = false; private String[] columnNames ={"s", "nome", "indirizzo", "path", "dimensione","directory", "contenuto"}; //private Object[][] data = {}; public void MyTable(Object[][] data, int co, Record[] r) { int i=0; //while(i!=co){ this.data=data; tm.addTableModelListener(e); // i++;} //addRow(TableModelEvent e); //System.out.println(r[i].getCliente()); } // public Object dato(Object data) // { //return data; //} public int getColumnCount() { try{} catch(Exception e){} return columnNames.length; } public int getRowCount() {try{} catch(Exception e){} return data.length; } public String getColumnName(int col) { try{} catch(Exception e){} return columnNames[col]; } public Object getValueAt(int row, int col) { try{} catch(Exception e){}return data[row][col]; } public Class getColumnClass(int c) { try{} catch(Exception e){}return getValueAt(0, c).getClass(); } public void addTableModelListener(TableModelEvent e) { int col = e.getColumn(); int row = e.getFirstRow(); } /* * Don't need to implement this method unless your table's * editable. */ public boolean isCellEditable(int row, int col) { //Note that the data/cell address is constant, //no matter where the cell appears onscreen. if (col < 0) { return false; } else { return true; } } /* * Don't need to implement this method unless your table's * data can change. */ public void setValueAt(Object value, int row, int col) { if (DEBUG) { System.out.println("Setting value at " + row + "," + col + " to " + value + " (an instance of " + value.getClass() + ")"); } data[row][col] = value; fireTableCellUpdated(row, col); if (DEBUG) { System.out.println("New value of data:"); printDebugData(); } } private void printDebugData() { int numRows = getRowCount(); int numCols = getColumnCount(); for (int i=0; i < numRows; i++) { System.out.print(" row " + i + ":"); for (int j=0; j < numCols; j++) { System.out.print(" " + data[i][j]); } System.out.println(); } System.out.println("--------------------------"); } }![]()

