title: Populate java.awt.list from String Array
body: <p>I am trying to populate my java awt list from a string array.
  The string array gets the values from a .csv file. (Timezones)
  e.g 
  Australia,Melbourne
  Australia,Sydney
  Europe,London</p>
  
  <p>Note: There are two list boxes. First one for region and second one for City.
  The idea is to have the second one update after the user selects a region in the first one.</p>
  
  <p>I can't seem to be able to populate the list from these values</p>
  
  <p>Any help will be appreciated
  Thanks</p>
  
  <pre><code>String fileName = "C:\\Users\\Seb\\IdeaProjects\\TimeMachine\\src\\regions.csv";
      File file = new File(fileName);
      try {
          Scanner inputStream = new Scanner(file);
          inputStream.useDelimiter(System.getProperty("line.separator")); //Stops the white spaces creating a new entry in array
          while (inputStream.hasNext()) {
              String data = inputStream.next(); //gets the whole line
              String[] arrayLocations = data.split(",");
              System.out.println(arrayLocations[0]);
              System.out.println(arrayLocations[1]);
  
              listRegion = Arrays.asList(arrayLocations);
          }
          inputStream.close();
  
      } catch (FileNotFoundException e) {
          e.printStackTrace();
  </code></pre>
  
  <p>The error appears in <code>listRegion = Arrays.asList(arrayLocations);</code></p>
  
  <p>Entire code</p>
  
  <pre><code>import java.applet.Applet;
  import java.awt.*;
  import java.awt.List;
  import java.io.*;
  import java.util.Arrays;
  import java.util.Scanner;
  
  public class TimeMachine extends Applet
  {
  private List listRegion = new List();
  private List listSubRegion = new List();
  
  public void init ()
  {
      setLayout(new BorderLayout());
  
      Panel buttons = new Panel(new BorderLayout());
      buttons.setBackground(Color.cyan);
      buttons.add(listRegion, BorderLayout.WEST);
      buttons.add(listSubRegion, BorderLayout.CENTER);
      add(buttons, BorderLayout.NORTH);
  }
  
  public void getLocationInfo()
  {
      String fileName = "C:\\Users\\Seb\\IdeaProjects\\TimeMachine\\src\\regions.csv";
      File file = new File(fileName);
      try {
          Scanner inputStream = new Scanner(file);
          inputStream.useDelimiter(System.getProperty("line.separator")); //Stops the white spaces creating a new entry in array
          while (inputStream.hasNext()) {
              String data = inputStream.next(); //gets the whole line
              String[] arrayLocations = data.split(",");
              System.out.println(arrayLocations[0]);
              System.out.println(arrayLocations[1]);
  
              listRegion = Arrays.asList(arrayLocations);
          }
          inputStream.close();
  
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>}</p>