if (jTable8.getSelectedRow() < 0 && jTable10.getSelectedRow() < 0) {
JOptionPane.showMessageDialog(this, "Please select mail to delete", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
NYM nym = new NYM();
if (jTabbedPane_Nymbox.getSelectedIndex() == 0) {
boolean success = nym.deleteMail(jTextField_NymID.getText(), Integer.parseInt((String) jTable8.getModel().getValueAt(jTable8.getSelectedRow(), 3)));
int previousSelection = jTable8.getSelectedRow();
if (success) {
//JOptionPane.showMessageDialog(this, "Mail deleted successfully", "Mail Deletion Success", JOptionPane.INFORMATION_MESSAGE);
((NYMBoxTableModel) jTable8.getModel()).setValue(nym.loadNymBox(jTextField_NymID.getText()), jTable8);
int newCount = jTable8.getModel().getRowCount();
if (newCount > 0) {
if (newCount > previousSelection) {
jTable8.setRowSelectionInterval(previousSelection, previousSelection);
} else {
jTable8.setRowSelectionInterval(previousSelection - 1, previousSelection - 1);
}
}
} else {
JOptionPane.showMessageDialog(this, "Mail deletion failed", "Error", JOptionPane.ERROR_MESSAGE);
}
} else {
boolean success = nym.deleteOutboxMail(jTextField_NymID.getText(), Integer.parseInt((String) jTable10.getModel().getValueAt(jTable10.getSelectedRow(), 3)));
int previousSelection = jTable10.getSelectedRow();
if (success) {
//JOptionPane.showMessageDialog(this, "Mail deleted successfully", "Mail Deletion Success", JOptionPane.INFORMATION_MESSAGE);
((NYMOutboxTableModel) jTable10.getModel()).setValue(nym.loadNymOutBox(jTextField_NymID.getText()), jTable10);
int newCount = jTable10.getModel().getRowCount();
if (newCount > 0) {
if (newCount > previousSelection) {
jTable10.setRowSelectionInterval(previousSelection, previousSelection);
} else {