NullPointerException « JList « Java Swing Q&A





1. Java Null Pointer Exception on JLIST    stackoverflow.com

OK so I'm trying to output the current string from an array that was put into a list... However when I click on the list I get a NullPointerException... :\ Help? :)

import java.applet.Applet;
import ...

2. JList - Null Pointer Exception    coderanch.com

If the line number that "String selectedAccount = accountJList.getSelectedValue().toString();" is on is the one that is reporting a null pointer exception, there are only two things that are causing it: either "accountJList" is null, or "getSelectedValue()" is returning null. You should try and test for both of these problems, but I'm guessing that it's the second. In fact, in the API ...