After inserting the data in a JTable, if you wish to remove any one row's data that is wrong entry then you must have to remove from the JTable. For removing the data of row from JTable, you will remove it from its table model. An implementation of DefaultTableModel that supports the removal data of row. Here providing you an example with code that removes some rows from a table.
Description of program:
This program creates a table with some data by using the DefaultTableModel that helps us for removing the data of row from a table. The removeRow() method is used to remove data at the specified index of row that have to removed from a table. Here the data of first and last rows are deleted by using the removeRow method. The following output will represent to it so, you will easily understood about it.
Description of code:
removeRow( int row_index ):
This method is used to remove the row from the model. It takes integer type row index that means its position or location in a table.
row_index: This is the index of row that have to removed.
Here is the code of program:
Output of program
Before removing rows:
After removing rows:
Liked it! Share this Tutorial