Java examples for Swing:JTable Model
Converts the selected view indexes to model indexes.
/*/*from w w w .j a v a 2 s. c om*/ * 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. */ //package com.java2s; 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; } }