0

I am trying to use the JavaMail API and using it in text when just fine. Printing out all my emails subjects in the cmd. So I wanted to implement it into a GUI.

For some reason though, I get a null error, even though I debugged the program and find that the array it uses to fill the DefaultTableModel is indeed full of stuff.

It seems to happen when the application is about to put the information in the model itself:

    try {
        for(Message m : message) {
            model.addRow(new Object[]{m.getFrom(), m.getSubject(), (m.getFlags().contains(Flags.Flag.SEEN) ? "Yes" : "No")});
        }
    } catch (MessagingException ex) {
        JOptionPane.showMessageDialog(paneParent, "An Error Occured:\n" + ex.getMessage(),
                "Error", JOptionPane.ERROR_MESSAGE);
    }

Any idea why this might happen? The array is not empty. I checked it.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
OmniOwl
  • 5,477
  • 17
  • 67
  • 116
  • 1
    We need to see the code where you create the JTable and the DefaultTableModel in order to help more. – george_h Jun 12 '12 at 10:47
  • 1
    Stacktrace plz. And place where error occured. – d1e Jun 12 '12 at 10:47
  • After closer inspection I think I know what the problem is...I get a "javax.mail.FolderClosedException". And I know where I close the folder I am reading, so..I need to print the StackTrace more often god damnit. – OmniOwl Jun 12 '12 at 10:51

1 Answers1

3

Problem solved.

I was an idiot for not checking the StackTrace. It held the "FolderClosedException" which led me to the solution.

OmniOwl
  • 5,477
  • 17
  • 67
  • 116
  • model.addRow(... should be wrapped into invokeLater :-), better would be prepare values as local variable (you can to test these values for whatever) and only tested variables put to the Model by wrapping into invokeLater – mKorbel Jun 12 '12 at 11:41