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

//A simple dialog that allows the user to respond to notification messages

public class ResponseDialog extends Frame implements ActionListener {

  public ResponseDialog(String messageId,ClientSocket clientsocket)
  {
    setSize(200,200);
    setLayout(null);
    
    Label reqlabel = new Label("Accept the meeting request?");
    add(reqlabel);
    reqlabel.setBounds(15,60,185,50);
    yesButton = new Button("Yes");
    noButton = new Button("No");
    add(yesButton);
    add(noButton);
    yesButton.addActionListener(this);
    noButton.addActionListener(this);
    yesButton.setBounds(30,105,50,50);
    noButton.setBounds(120,105,50,50);
    msgId = messageId;
    cs = clientsocket;
  }
  
  
  public void actionPerformed(ActionEvent evt)
  {
    String command;
    String arg = evt.getActionCommand();
    System.out.println("inside actionperformed of response dialog");
    command = "RESPONDTOMESSAGE" + "," + msgId + "," + arg;
    try
      {
	cs.Write(command);	
      }
    catch(IOException io)
      {
	System.out.println("IO error");
	
      }
    this.setVisible(false);
    dispose();
    validate();
    
  }
  
  private Button noButton;
  private Button yesButton;
  private String msgId;
  private ClientSocket cs;
}
