get Columns from Swing TableColumnModel - Java Swing

Java examples for Swing:JTable Model

Description

get Columns from Swing TableColumnModel

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public class Main {
    public static List<TableColumn> getColumns(TableColumnModel columnModel) {
        List<TableColumn> tablecolumns = new ArrayList<TableColumn>(
                columnModel.getColumnCount());
        for (int columnIndex = 0; columnIndex < columnModel
                .getColumnCount(); columnIndex++) {
            tablecolumns.add(columnModel.getColumn(columnIndex));
        }//from www. j a  va2s.c o  m

        return tablecolumns;
    }
}

Related Tutorials