jDialog1.dispose();
}//GEN-LAST:event_btnCancelActionPerformed
private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
//We need author object. Lets again fetch it from tablemodel
AuthorTableModel tableModel = (AuthorTableModel) jTable1.getModel();
int row = jTable1.getSelectedRow();
int age = 0;
Author author = tableModel.getRowObject(row);
author.setFull_name(txtAuthorFullName.getText());
try{
age = Integer.parseInt(txtAuthorAge.getText());
}catch(NumberFormatException e){
System.err.println("number not given, taken as 0");
//e.printStackTrace();
}
author.setAge(age);
author.setLocation(txtAuthorLocation.getText());
author.setDetails(txtAuthorDetails.getText());
AuthorModel authorModel = new AuthorModel();
int update_flag = authorModel.update(author);
if(update_flag == 1){
//tableModel.fireTableRowsUpdated(row-1, row+1);
tableModel.fireTableDataChanged();
jDialog1.dispose();
JOptionPane.showMessageDialog(this, "Author "+author.getFull_name()+" updated!", "Success!", JOptionPane.INFORMATION_MESSAGE);
}
}//GEN-LAST:event_btnUpdateActionPerformed