Java JTable Column getColumnNames(TableModel tableModel)

Here you can find the source of getColumnNames(TableModel tableModel)

Description

get Column Names

License

Open Source License

Parameter

Parameter Description
tableModel a parameter

Return

the list of column names of a table

Declaration

public static String[] getColumnNames(TableModel tableModel) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.table.TableModel;

public class Main {
    /**/*w ww.  jav  a 2 s. c  o  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;
    }
}

Related

  1. FitTableColumns(JTable myTable)
  2. formatStringListToTable(List columnNames, List rows)
  3. getColumnData(final JTable table, final int iSelectedRow)
  4. getColumnIndex(JTable table, String columnTitle)
  5. getColumnIndexFromName(TableModel tableModel, String columnToRemove)
  6. getColumnOrder(final JTable table)
  7. getColumns(TableColumnModel columnModel)
  8. getMultiLineColumnNames(String[] ret)
  9. getRealColumnPos(int colPos, JTable table)