Hey guys, this is my piece of code from a GUI that i am building, in which i have a button "Delete Row" and a table besides it which has, let's say 2 rows and 4 columns. Now when i select one of these rows, and press the "Delete row" button with the following code, nothing happens. I want that row to be deleted. Please help.
DefaultTableModel table_model;
JTable jt;
else if(e.getSource() == btnDel)//Action listener for the "Delete row" button
{
System.out.print("yo");
int selectedRow = jt.getSelectedRow();
while(selectedRow>0)
{
System.out.println("selectedRowCount=" + jt.getSelectedRowCount());
int modelRow = jt.convertRowIndexToModel(selectedRow);
table_model.removeRow(modelRow);
selectedRow = jt.getSelectedRow();
}
}