Returns The array list of JTable columns. - Java Swing

Java examples for Swing:JTable Column

Description

Returns The array list of JTable columns.

Demo Code


//package com.java2s;

import java.util.ArrayList;
import java.util.Enumeration;

import javax.swing.JTable;

import javax.swing.table.TableColumn;
import javax.swing.table.TableColumnModel;

public class Main {
    /**/*from www. jav a2 s .co m*/
     * Returns The array list of table columns.
     *
     * @param table The table.
     * @return The array list of table columns.
     */
    public static ArrayList<TableColumn> getTableColumns(JTable table) {
        ArrayList<TableColumn> list = new ArrayList<TableColumn>();
        TableColumnModel model = table.getColumnModel();
        Enumeration<TableColumn> enumeration = model.getColumns();
        while (enumeration.hasMoreElements()) {
            TableColumn column = enumeration.nextElement();
            list.add(column);

        }
        return list;
    }
}

Related Tutorials