I can do sorting and adding row separately with no problem. But when I combine the two features, I got a problem because of that two TableModels.
Here's how the whole thing initialized.
The sorting feature is fine, but the adding row is not. Here's how I add row.Code:/* Tasks extends vector TaskTableModel extends AbstractTableModel SortFilterModel extends AbstractTableModel */ Tasks tasks = new Tasks( new File( "data.xml" ) ); TaskTableModel tableModel = new TaskTableModel( tasks ); SortFilterModel sorterModel = new SortFilterModel( tableModel ); JTable table = new JTable( sorterModel );
Code:Task task = new Task( id, title, new Date() ); tasks.insertElementAt( task, 0 ); table.tableChanged( new TableModelEvent( tableModel, 0, 0, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT ) );
The following is the exception thrown when adding a row
So, any suggestion to resolve this?Code:java.lang.ArrayIndexOutOfBoundsException: 25 at SortFilterModel.getValueAt(SortFilterModel.java:50)



LinkBack URL
About LinkBacks


