title: How to display my JSON data in a comboBox?
body: <p>I have manged to read my JSONData and now I want to display the "name" key into a combobox.
  But i get a nullpointerexception of my string Array.
  Before I tried to send an JSON object straight into the defaultComboBoxModel. But it need to be and String Array so when I converted it everything became null.
  Why do my array get null? </p>
  
  <p>My code:</p>
  
  <pre><code>import java.util.ArrayList;
  import org.json.simple.JSONArray;
  import org.json.simple.JSONObject;
  
  
  public class Planner {
  
      private String startingLocation;
      private String destination;
      private static Planner planner = null;
      private int id;
      private JSONArray array;
      ArrayList myList = new ArrayList();
  
      public static Planner getPlanner(){
  
          if (planner == null ){
  
              planner = new Planner();
  
          }
  
          return planner;
  
      }
  
      public void setStartingLocation(String from) {
  
          this.startingLocation = from;       
  
      }
  
      public void setDestination(String dest) {
  
          this.destination = dest;
  
      }
  
      public String getStartingLocation() {
  
          return startingLocation;
  
      }
  
      public String getDestination() {
  
          return destination;
  
      }
  
  
      public void setID(int id) {
  
          this.id = id;
  
      }
  
      public void setLocationName (JSONArray array){
  
          this.array = (JSONArray) array;
  
      }
  
      public String[] getLocationName(){
  
          System.out.println(this.array.size());
  
        for (int i=0; i&lt;this.array.size(); i++){
  
             myList = (ArrayList) this.array.get(i);
             myList.add(i, array);
  
         }
  
         System.out.println(myList);
  
      return  (String[]) myList.toArray();
  
      }
  
  }
  
  public void parseJsonData() throws ParseException {
  
          JSONParser parser = new JSONParser();
          Object obj = parser.parse(jsonData);
          JSONObject topObject = (JSONObject) obj;
          JSONObject locationList = (JSONObject) topObject.get("LocationList");
          JSONArray array = (JSONArray) locationList.get("StopLocation");
          Iterator&lt;JSONObject&gt; iterator = array.iterator();
          String name = null;
  
          while (iterator.hasNext()) {
  
              JSONObject jsonObj = (JSONObject) iterator.next();
              Planner.getPlanner().setLocationName(array);
  
          }
  
      }
  
  final DefaultComboBoxModel model = new DefaultComboBoxModel(Planner.getPlanner().getLocationName());
          comboBox = new JComboBox(model); 
  </code></pre>