I am trying to update database by editing cell values in jtable. my table looks like
When i edit the value in particular cell and without clicking anywhere if i click on Update button the database is not updated as like this !
but if i click somewhere in the updating row, which again turns the look of table as fig. 1 then the database is upodated with particular value, why is this happening please help. My code for refresh Button goes like this:
int pos = recordTable.getSelectedRow();
int id = (Integer) recordTable.getModel().getValueAt(pos, 0);
ListSelectionModel selectionModel = recordTable.getSelectionModel();
selectionModel.setSelectionInterval(pos, pos);
String roomName = (String) recordTable.getValueAt(pos, 1);
int roomCharge = Integer.parseInt(recordTable.getModel().getValueAt(pos, 2).toString());
System.out.println(id + roomName + roomCharge);
recordTable.revalidate();
recordTable.repaint();
admin.updateRoomType(id, roomName, roomCharge);
please help!!