Java JTable Model convertSelectionToModel(JTable table)

Here you can find the source of convertSelectionToModel(JTable table)

Description

Converts the selected view indexes to model indexes.

License

LGPL

Parameter

Parameter Description
table the table

Return

the selected model indices

Declaration

public static int[] convertSelectionToModel(JTable table) 

Method Source Code

//package com.java2s;
/*//ww w.  j a v  a 2s .com
 * Copyright 2008-2014, David Karnok 
 * The file is part of the Open Imperium Galactica project.
 * 
 * The code should be distributed under the LGPL license.
 * See http://www.gnu.org/licenses/lgpl.html for details.
 */

import javax.swing.JTable;

public class Main {
    /**
     * Converts the selected view indexes to model indexes.
     * @param table the table
     * @return the selected model indices
     */
    public static int[] convertSelectionToModel(JTable table) {
        int[] selected = table.getSelectedRows();
        for (int i = 0; i < selected.length; i++) {
            selected[i] = table.convertRowIndexToModel(selected[i]);
        }
        return selected;
    }
}

Related

  1. compactDefaultTableModel(DefaultTableModel defaultTableModel)
  2. convertModelIndexToView(JTable table, int modelIndex)
  3. convertTableToList(DefaultTableModel table)
  4. dumpToText(TableModel m, String filename)
  5. fireTableDataChangedAndKeepSelection(final AbstractTableModel tableModel, final JTable table)
  6. getDefaultTableModel()