Java – How to remove a row from JTable?


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

Best 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: