Allora, questo è il programma:
Ma quando modifico una cella e premo invio, viene lanciata una ClassCastException... perchè?codice:import javax.swing.JFrame; import javax.swing.JTable; import javax.swing.JScrollPane; import javax.swing.table.AbstractTableModel; public class TestTable extends JFrame { private int[][] structure = new int[10][10]; public TestTable() { super ("Test Table"); setSize (400, 300); setLocationRelativeTo (null); setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); for (int i = 0; i < 10; i++) for (int j = 0; j < 10; j++) structure[i][j] = i * j; JTable table = new JTable ( new AbstractTableModel() { public int getColumnCount() { return 10; } public int getRowCount() { return 10; } public boolean isCellEditable (int row, int col) { return true; } public void setValueAt (Object aValue, int rowIndex, int columnIndex) { structure[rowIndex][columnIndex] = ((Integer) aValue).intValue(); fireTableCellUpdated (rowIndex, columnIndex); } public Object getValueAt (int row, int col) { return structure[row][col]; } public String getColumnName (int column) { return "Nome"; } } ); add (new JScrollPane (table)); setVisible (true); } public static void main (String[] args) { new TestTable(); } }VVoVe:

VVoVe:
Rispondi quotando