Alex Rivera | Logout

How to remove a row from JTable?

Asked 2009-07-13T06:02:15.653
18

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

Edit
Report

1 Answer

39

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);
answered 2009-07-13T06:29:33.650

Your Answer