Java JTable Row getTableRow(TableModel tableModel, int row)

Here you can find the source of getTableRow(TableModel tableModel, int row)

Description

Returns all cell values of a given table row ordered by their column indexes.

License

Open Source License

Parameter

Parameter Description
tableModel The <code>TableModel</code> from which the cell values should be read.
row Index of the row that should be processed.

Return

An array of Objects, where each index corresponds to the tableModel's column index and each value is the corresponding cell value.

Declaration

public static Object[] getTableRow(TableModel tableModel, int row) 

Method Source Code

//package com.java2s;
/*//from  w  ww . j a v a 2  s  .  co  m
 *  SalSSuite - Suite of programmes for managing a SalS project
 *  Copyright (C) 2011  Jannis Limperg <jannis[dot]limperg[at]arcor[dot]de>
 *
 *  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.table.TableModel;

public class Main {
    /**
     * Returns all cell values of a given table row ordered by their column
     * indexes.
     * @param tableModel The <code>TableModel</code> from which the cell values should
     * be read.
     * @param row Index of the row that should be processed.
     * @return An array of <code>Object</code>s, where each index corresponds
     * to the <code>tableModel</code>'s column index and each value is the
     * corresponding cell value.
     */
    public static Object[] getTableRow(TableModel tableModel, int row) {
        int columnCount = tableModel.getColumnCount();
        Object[] rowData = new Object[columnCount];
        for (int ct = 0; ct < columnCount; ct++)
            rowData[ct] = tableModel.getValueAt(row, ct);
        return rowData;
    }
}

Related

  1. getNullRow(TableModel tm)
  2. getReadableRow(JTable table, int maximumHiddenPart)
  3. getRealRowPos(int rowPos, JTable table)
  4. getRowBounds(JTable table, int first, int last)
  5. getRowByValue(TableModel model, Object value)
  6. hasRows(JTable table)
  7. insertRow(final JTable table, final int index, Object... data)
  8. isFirstToLastRow(TableModelEvent e)
  9. isRowInsert(TableModelEvent e)