public int [ ] getModelIndex ( ) { int [ ] modelIndex = new int [ model . getColumnCount ( ) ] ; try { TableColumnModel tcm = table . getColumnModel ( ) ; for ( int i = 0 ; i < model . getColumnCount ( ) ; i ++ ) { TableColumn tc = tcm . getColumn ( i ) ; modelIndex [ i ] = tc . getModelIndex ( ) ; } } catch ( java . lang . ArrayIndexOutOfBoundsException e ) { //can happen when model size increases } return modelIndex ; }
this array translates the column index to the model index