import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.*;

public class MessageTextArea extends TextArea implements MouseListener {

  public MessageTextArea(String message,ClientSocket clientsocket)
  {
    super(" ",100,100,TextArea.SCROLLBARS_VERTICAL_ONLY);
    String messageCode,sender,year,month,date,hour,minute,subject,messageBody;
    StringTokenizer tokenizer = new StringTokenizer(message,",");
    
    addMouseListener(this);

    messageCode = tokenizer.nextToken();
    responseId = tokenizer.nextToken();
    responseRequired = tokenizer.nextToken();
    sender = tokenizer.nextToken();
    year = tokenizer.nextToken("/");
    month = tokenizer.nextToken();
    date = tokenizer.nextToken();
    hour = tokenizer.nextToken();
    minute = tokenizer.nextToken("/,");
    subject = tokenizer.nextToken(",");
    messageBody = tokenizer.nextToken();

    append("Message sent: ");
    append(year);
    append(" ");
    append(month);
    append(" ");
    append(date);
    append(" ");
    append(hour);
    append(":");
    append(minute);
    
    append("\n");
    append("From: ");
    append(sender);
    append("\n");
    append("Subject: ");
    append(subject);
    append("\n\n");
    append(messageBody);
    append("\n");
    if( responseRequired.equals("yes"))
      append("Response Required");
    else
      append("No Response Required");

    cs = clientsocket;
  }

/*These methods will be removed once an inner class is added*/
  public void mouseClicked(MouseEvent evt)
  {
    System.out.println("mouseclicked\n");
    if(responseRequired.equals("yes"))
      {
	ResponseDialog response = new ResponseDialog(responseId,cs);
	response.setVisible(true);
	response.show();
      }
    
  }

  public void mousePressed(MouseEvent evt)
  {
    
  }
  public void mouseReleased(MouseEvent evt)
  {
    
  }
  public void mouseEntered(MouseEvent evt)
  {
    
  }
  public void mouseExited(MouseEvent evt)
  {
    
  }

  private String responseRequired;
  private String responseId;
  private ClientSocket cs;


}
