@Override public void actionPerformed(ActionEvent e) { try { int selectedRow = ListMailController.this.view.getSelectedRow(); if (-1 == selectedRow) { return; } int result = JOptionPane.showConfirmDialog( ListMailController.this.view, String.format("Are you sure you want to delete this mail?"), "Confirm", JOptionPane.YES_NO_OPTION); if (result == JOptionPane.YES_OPTION) { TotalListItem item = ListMailController.this.model.getItemAtRow(selectedRow); EncryptedListItem decryptedItem = item.getEncryptedListItem( null); // was already decrypted and cached, don't need private key WebServiceClient.deleteMessage(item.getId(), decryptedItem.getAttachments()); new RefreshListWorker().execute(); } } catch (IOException | FailedCryptException | JavaInstallationMissingComponentsException | IllegalStateException | CommunicationFailureException e1) { ListMailController.this.view.setInfo(Utils.ppStackTrace(e1)); } }