Java examples for Swing:JTable Column
get Column Names from JTable
//package com.java2s; import javax.swing.table.TableModel; public class Main { /**// w w w .j a v a 2 s . co m * @param tableModel * @return the list of column names of a table */ public static String[] getColumnNames(TableModel tableModel) { int size = tableModel.getColumnCount(); String[] columnNames = new String[size]; for (int i = 0; i < size; i++) { columnNames[i] = tableModel.getColumnName(i); } return columnNames; } }