import ReceptorEventos;
import java.awt.*;

public class PanelTertulia extends Panel
{
  ReceptorEventos jefe;
  public ListaCurso lisDebate;
  public TextField txtLinea;

  public PanelTertulia( ReceptorEventos jefe )
  {
     super();
     this.jefe = jefe;
     creaControles();
  }

  public void creaControles()
  {
     lisDebate = new ListaCurso(true);
     lisDebate.setBackground(Color.black);
     lisDebate.setForeground(Color.green);
     lisDebate.setFont( new Font("Courier",Font.PLAIN,9) );

     txtLinea = new TextField(60);
     txtLinea.setBackground(Color.blue);
     txtLinea.setForeground(Color.white);
     txtLinea.setFont( new Font("Courier",Font.PLAIN,9) );

     PanelCurso panSup = new PanelCurso(PanelCurso.RESALTADO, 5);
     panSup.setLayout( new BorderLayout() );
     panSup.add( "North", new Label("Debate:") );
     panSup.add("Center", lisDebate);
     panSup.add("South", txtLinea);

     PanelCurso panInf = new PanelCurso(PanelCurso.SIN_BORDE, 3);
     panInf.setLayout( new FlowLayout(FlowLayout.CENTER, 5, 1) );
     panInf.add( new Button("Salir") );
     panInf.add( new Button("Proponer Votacion") );

     setLayout( new BorderLayout() );
     add("Center", panSup);
     add("South", panInf);
  }

  public boolean action( Event evt, Object what )
  {
     if(evt.target==txtLinea) {
       String[] args = {txtLinea.getText()};
       jefe.nuevoEvento(this,ReceptorEventos.INT_LINEA,args);
       return(true);
     } else
     if(evt.target instanceof Button) {
        if(what.equals("Salir")) {
          jefe.nuevoEvento(this,ReceptorEventos.INT_FINTER,null);
          return(true);
        } else
        if(what.equals("Proponer Votacion")) {
          jefe.nuevoEvento(this,ReceptorEventos.INT_PROVOT,null);
          return(true);
        }
     }

     return( super.action(evt,what) );
  }

}
