title: Need assistance with list selection listener
body: <p>I'm trying to fill my list selection listener method with code, but I don't know how to approach it. Essentially, I would like for the method to fill multiple text fields when an item is selected from the JList.</p>
  
  <p>My JList looks like this: </p>
  
  <pre><code>private JList &lt;String&gt; contactList;
  private DefaultListModel&lt;String&gt; model;
  
  //Textfields
  comboBookType = new JComboBox(BookType.values());
  nameText = new JTextField("", 17);   
  authorText = new JTextField("", 17);   
  genreText = new JTextField ("", 17);
  comboCategory = new JComboBox (readCategory());
  
  //initialize defaultlistmodel and jlist
  model = new DefaultListModel &lt;String&gt;();
  bookList = new JList (model);
  bookList.setVisibleRowCount(10);
  bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  bookList.setFixedCellHeight (20);
  bookList.setFixedCellWidth (130);
  bookList.setBorder (BorderFactory.createLineBorder(Color.BLACK,1));
  JPanel left = new JPanel(new BorderLayout());
  left.add (new JScrollPane(bookList), BorderLayout.NORTH);
  bookList.addListSelectionListener (new ListSelection());
  
  //populating Jlist
  class openFileListener implements ActionListener
  {
  
      public void actionPerformed(ActionEvent e) 
      {
  
        book.getBooks();
        for (String name : addressBook.getBooks())
        {
          model.addElement(name);
        }
      }
  }
  
  //the getBooks() method in my Library class 
  public ArrayList&lt;String&gt; getBooks ()
  {
    File file;
    Scanner input;
    BookType type;
    ArrayList&lt;String&gt; books;
    ArrayList&lt;String&gt; names = new ArrayList&lt;String&gt;();
    try
    {
      file = new File ("Books.txt");
      input = new Scanner (file);     
  
      while (input.hasNext())
      {
  
        String line = input.nextLine ( );
        String [] book = line.split(",");
        type = BookType.valueOf(info[0]);
        String name = book[1];
        b = new Book (type, book[1], book[2], book[3], book[4], info[5]);
        list.add (b);
        information.add (name);
  
        numOfBooks++;
      }
      input.close ( );
    }
    catch (FileNotFoundException e)
    {
      JOptionPane.showMessageDialog (null, "File not found");
    }
    return information;
  }
  </code></pre>
  
  <p>Here's what I have so far in my list selection listener:</p>
  
  <pre><code>private class ListSelection implements ListSelectionListener
  {
    public void valueChanged (ListSelectionEvent e) 
    {
      book.getInfo ( );
      int index = bookList.getSelectedIndex ( );
  }
  
  
  //getInfo() method in Library class
  
  public ArrayList&lt;Book&gt; getInfo ()
  {
    File file;
    Scanner input;
    BookType type;
    ArrayList&lt;String&gt; book;
    try
    {
      file = new File ("Book.txt");
      input = new Scanner (file);     
  
      while (input.hasNext())
      {
        String line = input.nextLine ( );
        String [] info = line.split(",");
        type = BookType.valueOf(info[0]);
        String name = info[1];
        Book b = new Contact (type, info[1], info[2], info[3], info[4],info[5]);
        list.add (b);
      }
      input.close ( );
    }
    catch (FileNotFoundException e)
    {
    JOptionPane.showMessageDialog (null, "File not found");
    }
    return list;
  </code></pre>
  
  <p>It's not much, but I have no ideas on where to go from here.  I know I have to utilize the <code>index</code> that I got from from <code>getSelectedIndex</code> but I don't know how, please help, thank you. </p>