How to show confirmation Delete message before we really delete some data? (this case use java programming and jButton as action Perform...
How to show confirmation Delete message before we really delete some data? (this case use java programming and jButton as action Performed ),lets follow those ways:
The First : Create msg variable like this code:
int msg=JOptionPane.showConfirmDialog(null,"Do you really wan to delete ?"
,"Delete",JOptionPane.YES_NO_OPTION );
The Second : Create IF condition like the code below and put the action delete code (unbold font) if msg==0
look at the code:
if(msg==0){
try{
String sql="delete from db_user "
+ "where id_user=?";
ps=(PreparedStatement) conn.prepareStatement(sql);
ps.setInt(1,76 );
ps.execute();
glasspaneMessage.setMessage("Data Deleted");
}catch(SQLException | HeadlessException e){
JOptionPane.showMessageDialog(null, e);
}
}