Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Converts a column index in the model to a visible column index

import javax.swing.JTable; import javax.swing.table.TableColumn; public class Main {   public static void main(String[] argv) throws Exception {   }   public int toView(JTable table, int mColIndex) {     for (int c = 0; c < table.getColumnCount(); c++) {       TableColumn col = table.getColumnModel().getColumn(c);       if (col.getModelIndex() == mColIndex) {         return c;       }     }     return -1;   } }