Java JTable Column getColumnOrder(final JTable table)

Here you can find the source of getColumnOrder(final JTable table)

Description

Returns the column order of a table in a formatted String .

License

Open Source License

Parameter

Parameter Description
table The table to get the column order from

Return

A string in the format "0 1 2 3"

Declaration

public static String getColumnOrder(final JTable table) 

Method Source Code

//package com.java2s;
/*/* www  .  j  ava 2 s  . c  o  m*/
 * jGnash, a personal finance application
 * Copyright (C) 2001-2017 Craig Cavanaugh
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import javax.swing.JTable;

public class Main {
    /**
     * Returns the column order of a table in a formatted
     * {@code String}.
     *
     * @param table The table to get the column order from
     * @return A string in the format "0 1 2 3"
     */
    public static String getColumnOrder(final JTable table) {
        StringBuilder buffer = new StringBuilder();
        int count = table.getColumnCount();
        for (int i = 0; i < count; i++) {
            if (i > 0) {
                buffer.append(' ');
            }
            buffer.append(table.convertColumnIndexToModel(i));

        }
        return buffer.toString();
    }
}

Related

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