How to remove a row from JTable?

java, jtable, swing

Solution

In order to remove a row from a JTable, you need to remove the target row from the underlying TableModel. If, for instance, your TableModel is an instance of DefaultTableModel, you can remove a row by doing the following:

((DefaultTableModel)myJTable.getModel()).removeRow(rowToRemove);

Problem

I want to remove some rows from a JTable. How can I do it?

Original source