import java.awt.*;
import java.awt.event.*;
 
/**
 * CSC 442F:    Software Engineering
 * Software:    Calendar Client
 * Component:   DonePanel class
 * Description: The DonePanel class produces a panel with buttons 
 *              "Ok", "Help" and "Cancel". 
 * @author David Tam
 * @version 1.0
 */
public class DonePanel extends Panel implements ActionListener
{ 
  protected MeetingDialog parent;

  // Buttons
  protected Button ok;
  protected Button cancel;
  protected Button help;
  
  // GridBagLayout constraints
  protected GridBagConstraints constraints;

 /** 
  * Constructor
  * ===========
  *
  * @param parent_in   Passes container for disposal operations
  */
  public DonePanel(MeetingDialog parent_in)
  {
    parent = parent_in;
    
    // Button instantiation
    ok     = new Button("Ok");
    cancel = new Button("Cancel");
    help   = new Button("Help");

    // Constraints instantiation
    constraints = new GridBagConstraints();

    // Button event recievers
    cancel.addActionListener(this);
    ok.addActionListener(this);
    help.addActionListener(this);

    // Panel layout
    setLayout(new GridBagLayout());
    constraints.gridy=0;
    constraints.gridx=0;
    constraints.insets= new Insets(20,125,20,30);
    add(ok, constraints);
    constraints.gridx=1;
    constraints.insets= new Insets(20,30,20,30);
    add(help, constraints);
    constraints.gridx=2;
    constraints.insets= new Insets(20,30,20,125);
    add(cancel, constraints);
    constraints.insets= new Insets(0,0,0,0);    
  }
  
  
  // Method to handle action events
  // ==============================
  public void actionPerformed(ActionEvent event)
  {
    // Determine who caused the event
    if (event.getSource() == cancel)
      // Return without making changes
      parent.dispose();
    else if (event.getSource() == ok)
      // Grab values from components
      parent.grabValues();
    else if (event.getSource() == help)
      // Call help dialog
      parent.help();
  }


}
