Java examples for Swing:JTable Column
get JTable Column Index From Name
//package com.java2s; import javax.swing.table.TableModel; public class Main { /**//from ww w.j a va 2s.c o m * @param tableModel * @param columnToRemove * @return the index of the column, where the column name is the string */ public static int getColumnIndexFromName(TableModel tableModel, String columnToRemove) { for (int columnIndex = 0; columnIndex < tableModel.getColumnCount(); columnIndex++) { if (tableModel.getColumnName(columnIndex) .equals(columnToRemove)) { return columnIndex; } } return -1; } }