
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.border.*;
import javax.accessibility.*;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
//-----------------------------------
public class MedDemo extends JxFrame
   implements ActionListener
{
   KidList kidList;
   PickedKidsList picked;
   KTextField tx;
   MoveButton Move;
   ClearButton Clear;
   Mediator med;
   
   public MedDemo()
   {
      super("Mediator demo");
      
      JPanel jp = new JPanel();
      getContentPane().add(jp);
      jp.setLayout(new BorderLayout());
      JPanel center = new JPanel();
      JPanel left = new JPanel();
      JPanel right = new JPanel();
      jp.add("Center", center);
      center.setLayout(new GridLayout(1,2));
      center.add(left);                           
      center.add(right);

      left.setBorder(new EmptyBorder(5,5,5,5));
      right.setBorder(new EmptyBorder(5,5,5,5));

      Mediator med = new Mediator();
      kidList = new KidList(med);
      med.registerKidList (kidList);
      left.setLayout(new BorderLayout());
      left.add("Center", kidList);
      
      right.setLayout(new BorderLayout());
      tx = new KTextField(med);
      med.registerKidText (tx);

      Move = new MoveButton(this, med);
      Clear = new ClearButton(this, med);
      JPanel rtop = new JPanel();
      jp.add ("North", rtop);
      rtop.add(tx);
      rtop.add(Move);
      rtop.add(Clear);
      picked =new PickedKidsList(med);
      med.registerPickedList (picked);

      right.add("Center", picked);
      
      
      med.registerMoveButton (Move);
      //med.init();
      setSize(new Dimension(400,300));
      setVisible(true);
   }
   //---------------------------------------
   public void actionPerformed(ActionEvent e)
   {
      Command comd = (Command)e.getSource();
      comd.Execute();
   }
   //---------------------------------------
   static public void main(String argv[])
   {
      new MedDemo();
   }
}
