本文共 462 字,大约阅读时间需要 1 分钟。
加入确认框后需要对其添加验证操作才能够有效地进行确认操作,否则没有意义。
添加验证操作如下程序所示:
//添加确认提示框,会返回一个整数int isDelete = JOptionPane.showConfirmDialog(null, "确定删除", "提示", JOptionPane.YES_NO_CANCEL_OPTION);//如果这个整数等于JOptionPane.YES_OPTION,则说明你点击的是“确定”按钮,则允许继续操作,否则结束if(isDelete == JOptionPane.YES_OPTION){ DepartmentDaoImpl deptDao = new DepartmentDaoImpl(); Department d = deptDao.findByPK(data[table.getSelectedRow()][0]); deptDao.delete(d); JOptionPane.showMessageDialog(null, "删除成功");}
转载地址:http://nvtlf.baihongyu.com/