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 Mediator
{
 private ClearButton clearButton;
 private MoveButton moveButton;
 private KTextField ktext;
 private KidList klist;
 private PickedKidsList picked;

 public Mediator() {
     
 }
 //------------------------------------
 public void registerKidText(KTextField ktx) {
    ktext = ktx;
 }
 public void registerKidList(KidList klst) {
    klist = klist;
 }
 public void registerPickedList(PickedKidsList pklst) {
    picked = pklst;
 }
 //------------------------------------
 public void action(MoveButton mv)
 {
   picked.add(ktext.getText());
    moveButton = mv;
    if(clearButton != null)
      clearButton.setEnabled(true);

 }
 //------------------------------------
 public void action(ClearButton clrButton)
 {
    ktext.setText("");
    moveButton.setEnabled(false);
    clearButton = clrButton;
    clearButton.setEnabled(false);

    picked.clear();
    klist.clearSelection();
  }
 //------------------------------------
 public void action(KidList klst)
 {
    klist = klst;
    String s = (String)klist.getSelectedValue();
    ktext.setText(s);
    moveButton.setEnabled(true);
 }
 //------------------------------------
 public void registerMoveButton(MoveButton mvb) {
    moveButton = mvb;
 }

}
