I am trying to make a reply Form using NetBeans gallery. I am using JList
to view my messages and when I would like to reply to a specific message I got Null Pointer Exception. This my code: I made two constructors one to make a JFrame
and the other to set getFrom() method in to.Text().
public class ReplyForm extends javax.swing.JFrame {
private JList theList;
ReplyForm(JList inputList) throws IOException, MessagingException {
theList = inputList;
// System.out.println(theList);
if (theList != null) {
int i = theList.getSelectedIndex();
Email email = (Email) theList.getModel().getElementAt(i);
Message message = email.getMessage();
to.setText(message.getFrom()[0].toString());
subject.setText("RE: " + message.getSubject());
text.setText((String) message.getContent());
}