// Form to display list of phones 
import  java.awt.*;
import  java.awt.event.*;
import  javax.swing.*;
public class ListPhones extends JFrame  implements ActionListener
{
 JButton b1;
 PhoneBook pb;
 JTextArea  ta;
   public ListPhones(PhoneBook pb)
   {
     super("List of Phones");
     this.pb = pb;
     b1= new JButton("Exit");
     b1.addActionListener(this);
     ta = new JTextArea();     
     Container c  = getContentPane();
     c.setLayout(new BorderLayout());
     JScrollPane sp = new JScrollPane(ta,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
     c.add(sp,"Center");
     c.add(b1,"South");
     setSize(300,200);
     setVisible(true);
     ta.setText(pb.getAllEntries());
      ta.setEditable(false);

   } // end of init

   public void actionPerformed(ActionEvent evt)
   {
     if ( evt.getSource() == b1 )
           this.setVisible(false);
   }
} // end of class