Java JTable Row Delete deleteSelectedRows(JTable table)

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

Description

delete Selected Rows

License

Apache License

Declaration

public static void deleteSelectedRows(JTable table) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.swing.*;

import javax.swing.table.DefaultTableModel;

public class Main {
    public static void deleteSelectedRows(JTable table) {
        DefaultTableModel model = (DefaultTableModel) table.getModel();
        int[] rows = table.getSelectedRows();

        for (int rowIndex = 0; rowIndex < rows.length; rowIndex++) {
            model.removeRow(rows[rowIndex] - rowIndex);
        }//  w  w w  . j  a v a 2s.  co m
    }
}

Related

  1. deleteAllRows(JTable table)
  2. delSelectedRows(JTable table)
  3. removeAllRows(JTable table)
  4. removeAllRows(JTable table)
  5. removeAllRows(JTable... tables)