diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 1da43ce..93921d9 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -58,9 +58,11 @@ public void close() throws Exception { System.out.println("Closing connection to: " + account.host()); if (emailFolder != null) { emailFolder.close(); + emailFolder = null; } if (emailStore != null) { emailStore.close(); + emailStore = null; } } } @@ -146,12 +148,8 @@ private static List getAccounts() { static class MultiLineTableModel extends AbstractTableModel { private final List data = new ArrayList<>(); - public void addRow(Message message) { - try { - data.add(new String[] {getDate(message), getFrom(message), getSubject(message)}); - } catch (Exception e) { - throw new RuntimeException(e); - } + public void addRow(Message message) throws Exception { + data.add(new String[] {getDate(message), getFrom(message), getSubject(message)}); fireTableDataChanged(); } @@ -230,7 +228,7 @@ private void updateLastIndex() { } private static Map> messages = new LinkedHashMap<>(); - private static int max_mails = 6; + private static volatile int max_mails = 6; private static String getDate(Message message) throws Exception { return message.getSentDate().toString(); @@ -315,18 +313,18 @@ private static void createGUI() { .addDocumentListener( new DocumentListener() { public void changedUpdate(DocumentEvent e) { - upd(); + update(); } public void removeUpdate(DocumentEvent e) { - upd(); + update(); } public void insertUpdate(DocumentEvent e) { - upd(); + update(); } - public void upd() { + public void update() { String s = maxField.getText(); if (!s.isBlank()) { try { @@ -398,7 +396,7 @@ public void windowClosing(WindowEvent e) { public static void main(String[] args) { try { - createGUI(); + SwingUtilities.invokeLater(Main::createGUI); } catch (Exception e) { JOptionPane.showMessageDialog( null,