0

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();
			}
            
		}
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by mKorbel
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.