// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// $Id: UtterancePanel.java,v 1.2 2003/03/06 00:40:39 moltmans Exp $
// UtteranceFrame.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Thu Feb 24 18:15:21 2000> 
// Time-stamp: <2001-02-05 15:07:17 moltmans> 
package rec.ui;

import java.awt.event.*;
import java.util.*;
import javax.swing.JButton;
import javax.swing.JLabel;
import rec.speech.RecListen;
import rec.sys.WUtterance;
import javax.swing.JTextField;
import java.awt.GridLayout;
import javax.swing.JPanel;

/**
 * This class provides a mechanism for displaying utterances as they
 * are spoken.  This is in keeping with the explicit feed back
 * paradigm.
 **/
public class UtterancePanel extends JPanel
{
  private JTextField m_field;

  public UtterancePanel() 
  {
    m_field = new JTextField(20);
    ActionListener al = new ActionListener() {
      public void actionPerformed( ActionEvent e ) {
	RecListen.getListen().processString( e.getActionCommand() );
	m_field.selectAll();
      }
    };

    m_field.addActionListener( al );

    JButton button = new JButton( "Send text" );
    ActionListener bl = new ActionListener() {
      public void actionPerformed( ActionEvent e ) {
	RecListen.getListen().processString( m_field.getText() );
	m_field.selectAll();
      }
    };
    button.addActionListener( bl );

    //    setLayout( new GridLayout(1,3) );
    add( new JLabel( "Enter verbal annotations:" ) );
    add( m_field );
    add( button );
  }

  public void addUtterance( WUtterance utterance ) 
  {
    m_field.setText(utterance.getTags().getText());
    m_field.selectAll();
  }
}
