title: Actionlistener outputing Jlist info to textarea
body: <p>Could someone help me with the following problem? I want to implement a actionlistener that outputs info about the highlighted Jlist object into the already present textarea. </p>
  
  <p>Here is the code i've managed to cook up:</p>
  
  <pre><code> import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
  
    public class ListModel extends JFrame {
  
     private JList list;
     private DefaultListModel model;
     private JTextField inputf;
     private JTextField inpute;
     private JTextArea text;
     private JPanel p1;
     private JPanel p2;
  
      public ListModel() {
        setLayout(new FlowLayout());
        model = new DefaultListModel();
        list = new JList(model);
        JButton addButton = new JButton( "Lägg till" );
        model.addElement("Kajsa Åslund");
        model.addElement("Erik Carlsson");
        model.addElement("John Åkesson");
        model.addElement("Per-arne Ingvarsson");
        model.addElement("Rebecka Asp");
        model.addElement("Linnéa Åslund");
        model.addElement("Åsa-Nisse Strong");
        model.addElement("Super Lasse");
        model.addElement("Alexander Ahl");
        model.addElement("Ann Ahl");
        model.addElement("Bo Sten");
       addButton.addActionListener(
       new ActionListener() {
          public void actionPerformed( ActionEvent event )
                       {
                       final String name=inputf.getText() + " " + inpute.getText();
  
                       model.addElement( name );
                   }
               }
               );
       JButton removeButton =
       new JButton( "Ta bort" );
  
       removeButton.addActionListener(
           new ActionListener() {
  
           public void actionPerformed( ActionEvent event )
               {
               setTitle("Borttagning");
               try
              {
              Thread.sleep(1000);
              }
              catch(InterruptedException e)
              {
              e.printStackTrace();
              }
               model.removeElement(list.getSelectedValue());
               setTitle("Personer");
           }
       }
       );
  
       text = new JTextArea(5, 20);
  
       inputf = new JTextField();
       inputf.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
  
          }
  
      });
       inpute = new JTextField();
       inpute.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
  
          }
  
      });
       list.setSelectionMode(
       ListSelectionModel.SINGLE_SELECTION );
  
       inpute.setBounds(5, 5, 100, 100);
       inpute.setPreferredSize(new Dimension(120,20));
       inputf.setBounds(10, 10, 150, 150);
       inputf.setPreferredSize(new Dimension(120,20));
       JScrollPane scroll = new JScrollPane(list);
       scroll.setPreferredSize(new Dimension(200,200));
  
       JPanel p2 = new JPanel();
       p2.add(text);
       p2.add(inputf);
       p2.add(inpute);
       p2.add(addButton);
       p2.add(removeButton);
       p2.setLayout(new BoxLayout(p2,BoxLayout.Y_AXIS));
  
       JPanel p1 = new JPanel();
       p1.add(scroll);
  
  
       Container container = getContentPane();
       container.add(p1);
       container.add(p2);
       container.setLayout(new FlowLayout());
  
       setDefaultCloseOperation( EXIT_ON_CLOSE );
       setSize( 500, 250 );
       setVisible( true );
   }
  
     public static void main( String args[] )
           {
           new ListModel();
       }
     }
  </code></pre>
  
  <p>Thanks in advance :)</p>